我的页面分为vertically
两部分。 Left part
就像一个菜单部分。点击 任何菜单都会在页面的right part
中显示与该菜单相关的正确数据。我 使用ajax call
这样做,唯一的div on the right part
得到刷新。我使用jquery点击事件的.. 说:为什么有时候jquery点击事件失败?
$("#left_part").click(function() { // ajax call here });
现在我对right part
一些jquery action
。 (说明隐藏一些也适用于click event.
的div) 但是当new div reloads
在右边部分那些click event on the right part
不起作用。 但是,当我bind the click event
它的作品。
说:
$("#some_right_part").click(function() {/ some hide show here)}; Not working
$("#some_right_part").bind('click', function(event){ // some hide show here)}; works fine
重要:当我在fresh page
(没有AJAX调用尚未使右边部分)$("#some_right_part").click(function() {/ some hide show here)}; works fine.
但我知道的是:$().click(function)
电话$().bind('click',function)
那么,背后的原因是什么?或什么是当你在页面加载时,单击事件被绑定到所有匹配的元素通过$().click
分配一个click事件来解决这样的问题
感谢
这应该不会像您所描述的那样失败,它可能是别的。如果你使用'click'发布你的整个代码块失败,这将是有帮助的。 – hunter 2011-05-11 13:39:49