I am building a webpage that loads new ‘pages’ by loading XML files and then changing the content. The issue I am having is that when the data is loaded, the selectors are not working. The error occurs when I load a gallery. Each image has a class “thumbs”. The image loads fine, but the $(“thumbs”).click() code in my js does not work. Is there some issue with that object being loaded that would cause jquery to not find it when looking for selectors?
Share
You’re missing the class-selector code, specifically, the dot:
.. Change your click event to this:And it should work, though, if this content is loaded dynamically, you will need to use the .on() method as others have mentioned: