So I use .load to show some information from php files that output data. I want to use .load so I can refresh this data once in a while or upon a particular action. Unfortunately this affects other parts of my site. There is a button that is outputted which jquery normally intercepts. Although now I cannot select the class as it doesn’t seem to be in my source code due to having used .load.
How can I get around this issue?
Thanks
From my understanding you need to use jquery on() to setup the click event on your button. It is not that your button does not exist, but rather it is recreated. Therefore, your initial selector will not work unless you set it up using on(). Your code would look something like this:
The above code will find a static element on the page (preferably the parent of the dynamically loaded content) and will look for all elements with the class specified in the second argument. It will then attach the specified event found in the first argument to all of the found elements even if they were created after the initial pageLoad.
Just as a note, jQuery on() is for versions of jquery 1.7.1 or higher. If you are using earlier version you would want to use live().