Can I have two JavaScript onclick events in one element?

后端 未结 5 606
南旧
南旧 2020-12-13 10:00

Can we put two JavaScript onclick events in one input type button tag? To call two different functions?

5条回答
  •  执笔经年
    2020-12-13 10:39

    This one works:

    And this one too:

    function Hey()
    {
        alert('hey');
    }
    
    function Ho()
    {
        alert('ho');
    }
    

    .

    
    

    So the answer is - yes you can :) However, I'd recommend to use unobtrusive JavaScript.. mixing js with HTML is just nasty.

提交回复
热议问题