Code
$ (function () {
$ ("#btn"). Click (function () {
Console.log (2)
})
$ ("#btn"). Click (function () {
Console.log (1)
})
$ ("#btn"). Click (function () {
Console.log (3)
})
})
The result of this click is output 2,1,3
Because you are here to bind the click, he still has the first event before you can unbind it, so he will continue the previous one;
Native
document.getElementById ("Btn"). AddEventListener ("click", Function () {
Console.log (10)
},false)
document.getElementById ("Btn"). AddEventListener ("click", Function () {
Console.log (11)
},false)
document.getElementById ("Btn"). AddEventListener ("click", Function () {
Console.log (},false);
and the onclick:
is a re-assignment, variable promotion
document.getElementById ("Btn"). Onclick=function () {
Console.log (1)
}
document.getElementById ("Btn"). Onclick=function () {
Console.log (2)
}
document.getElementById ("Btn"). Onclick=function () {
Console.log (3)
}
The end result is 3.
About onclick and AddEventListener (' click '), click on the Finishing