jQuery中的addEventListener

Dia*_*ana 8 javascript jquery javascript-events addeventlistener

可能重复:
jQuery相当于JavaScript的addEventListener方法

还有一个非常好的jQuery教程:http://itunes.apple.com/in/app/designmobileweb/id486198804?mt = 8

以下语句的jQuery等价物是什么;

element1.addEventListener('click',doSomething2,false)
Run Code Online (Sandbox Code Playgroud)

如果是bind()方法,是否有任何选项来指定最后一个参数(即事件冒泡或捕获... true/false)

谢谢.

Sha*_*oli 12

试试这个

// Setting the third argument to false will attach a function
// that prevents the default action from occurring and 
// stops the event from bubbling.
$("#element1").bind("click", doSomething2, false);
Run Code Online (Sandbox Code Playgroud)