$().ready(function(){
$("#move-to").click(function(){
$("body").bind("click",function(){
alert("foo");
});
});
});
Why I see alert(“foo”) immediately after click on “move-to”?
When I bind “alert” on some div in document evrithing is ok.
Can come somebady help?
What I’m doing wrong?
After your
#move-tohandler runs, the click event bubbles up to the<body>, firing the handler you just bound.You can prevent that by calling
e.stopPropagation().Alternatively, you can bind the
<body>click event after this event cycle by moving thebind()to asetTimeoutcall.