开发者

Jquery binds the click events sequentially after every .load()

开发者 https://www.devze.com 2023-03-14 12:46 出处:网络
I am loading a .php file into a div tag using .load() function of jquery : $(\'#content\').load(\'MY_URL\');

I am loading a .php file into a div tag using .load() function of jquery :

$('#content').load('MY_URL');

I have bound several events using .l开发者_运维问答ive and all of them work fine after loading the MY_URL. but the problem is : when I load the second page into the latter loaded page (suppose #content) the events are fired twice : for example I have bound a click event to show and hide a div tag but after loading the second page it fires two times and shows and hide the div tag sequentially that you can say it doesn't work at all.

I have read all problems like this and I can say all their problems have been solved using .live instead of .bind but mine did not get solved ! please help me.


Unbind your first live event before firing 2nd live event

$('#content').die("click");

0

精彩评论

暂无评论...
验证码 换一张
取 消