How to 'refresh' the code source the jQuery will detect again?
Hey there,
I've been using jQuery for a couple years now and I just ran into a problem.
I've had this problem before but I forgot how I resolved the problem and I can't find it anywhere anymore either.
Here is the problem:
I have a simple html form with some <select>'s. Once one is hit, jquery will use $.post to get new content from a php file and update the contents in a div with new form items (new <select>'s).
Now I want to be able to use these selects with ajax too, however, the .change function will not work on them because for some reason, jQuery does not recognize the newly loaded elements (through ajax). How to make jQuery find these elements? I.e. how to 'refresh' the source code without refreshing the page?
For testing purposes, I use this code:
- $("select").change(function() {
- alert('test');
- });
It will alert the first time when I select an item which makes jQuery update the rest of the form through ajax, but the newly inserted <select>'s will not give me any alerts anymore.
Please help me out!
Thanks for your time and greetings,
Rien Heuver