使用jQuery在单个元素上不引人注目的多个事件处理程序
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了使用jQuery在单个元素上不引人注目的多个事件处理程序相关的知识,希望对你有一定的参考价值。
/* Example of inline event handlers: <input type="text" name="date" onchange="validateDate()" /> This is bad. The purpose of markup is to describe a document's structure, not its programmatic behavior. And what if we need to set handlers for several events on a single element? */ // The unobtrusive solution: <input type="text" name="date" id="date" /> /* A script that runs when page is loaded into the browser, looks for relevant element(s) and set them up accordingly: (using jquery) */ var message = "mouse entered or left."; // passing the variable in by value through eventData: $('#date').bind('mouseenter mouseleave', {msg: message}, function(event) { alert(event.data.msg); });
以上是关于使用jQuery在单个元素上不引人注目的多个事件处理程序的主要内容,如果未能解决你的问题,请参考以下文章