頁面有時候要增埋監聽事件,又怕被綁在物件上的事件影響時,有以下順序可以作為參考切入點

EX:
1. 連結裡埋一個onclick事件
2. 連結設為 https://www.google.com.tw/ 
3. 再分別設3個監聽.on()事件

<a id="testID" onclick="alert('tagOnclick');" href="https://www.google.com.tw/">
For test
</a>
$("#testID").on('click', function(event){
    alert("1");
});

$("#testID").on('click', function(event){
    alert("2");
});

$("#testID").on('click', function(event){
    alert("3");
});

 

RESULT:

alert('tagOnclick');
alert('1');
alert('2);
alert('3');
location to https://www.google.com.tw/

 

arrow
arrow
    文章標籤
    javascript .on() onclick href
    全站熱搜

    咪卡恰比 發表在 痞客邦 留言(0) 人氣()