//一个标签绑定多个事件
$('.gejin').on('click mouseover',function(){
$('.gejin,.xiechang').css('color','blue');
})
//多个标签绑定多个事件
$('.xiechang,.gejin').on({
click:function(){alert('sss')},
mouseover:function(){$(this).css('color','red')},
mouseout:function(){$(this).css('color','blue')}
})
//一个标签绑定多个事件
js:
var gejin = document.getElementsByClassName("gejin")[0];
gejin.addEventListener('click',function(){
alert('aa')
})
gejin.addEventListener('mouseover',function(){
alert('aa')
})
addEventListener
("事件名","事件触发时执行的函数","false或者true")
document.getElementById("add").addEventListener("click",function(){
alert('子')
},true);
document.getElementById("parent").addEventListener("click",function(){
alert('父')
},true);
true时,先alert('父');false时,先alert('子');
false表示指定事件在冒泡阶段执行,true表示指定事件在捕获阶段执行