也来自一个非常好的jQuery教程:http://itunes.apple.com/in/app/designmobileweb/id486198804?mt=8
以下语句的jQuery等效值是什么;
element1.addEventListener('click',doSomething2,false)如果是bind()方法,是否有任何选项来指定最后一个参数(即事件冒泡或捕获.(真/假)
发布于 2011-08-11 12:04:45
尝尝这个
// 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);发布于 2011-08-11 12:03:55
是的,我很确定.bind()会根据您的需要工作。看看jQuery .bind() docs页面,我相信你能搞清楚这个设置。演示代码如下:
$(document).ready(function() {
$("#element1").bind('click', function() {
// do something on click
}
});发布于 2011-08-11 12:01:09
使用jquerys 绑定法
示例:
document.bind("custom-listener", someCustomFunction, false);
document.trigger("custom-listener", {jsonArgsKey:jsonValue});
function someCustomFunction(json)
{
alert(json.jsonArgsKey);
}https://stackoverflow.com/questions/7025437
复制相似问题