简体   繁体   中英

JQuery: After adding some AJAX, some of the jquery code no longer works

Here's a pastebin link to my entire jQuery code. [ http://pastebin.com/w57ma5Gx ] The "Thumbnails" section was working fine before I added the ajax sections. Anyone can help me with why it quit working? Thanks!

Just use a .live click handler on your thumbnails, which I assume are getting replaced by your ajax call, instead of the 'classic' click handler:

$("img.thumbs").live("click", function()                                
{
    var imgLink = $(this).attr("src");                                     
    $("img#spotlight").attr("src", imgLink);                       

});

That way, you will attach a click handler "for all elements which match the current selector, now and in the future" .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM