jQuery如何使用on()方法
请使用'On'
在新版jQuery中,更短的 on(“click”) 用来取代类似 click() 这样的函数。在之前的版本中 on() 就是 bind()。自从jQuery 1.7版本后,on() 附加事件处理程序的首选方法。然而,出于一致性考虑,你可以简单的全部使用 on()方法。
// 糟糕$first.click(function(){ $first.css('border','1px solid red'); $first.css('color','blue');});$first.hover(function(){ $first.css('border','1px solid red');})// 建议$first.on('click',function(){ $first.css('border','1px solid red'); $first.css('color','blue');})$first.on('hover',function(){ $first.css('border','1px solid red');})
本文标题:jQuery如何使用on()方法
本文链接:https://www.qqooo.cn/post/6940.html
版权说明:网站文章均来源于手工整理和网友投稿,若有不妥之处请来信 xsds@vip.qq.com 处理,谢谢!