javascript - jQuery fn() isn't loading / working? -


there 1 div changes it's innerhtml ajax. once page loads, jquery function() works when innerhtml changes ajax functionality doesn't work. checked code using firebug , try explain in short.**

i think dom loads js file when page loaded first time , if ajax modifies innerhtml function not invoked somehow.what say? solution according you? html page

 <body>      <div class="_div_change"> dynamically class add jquery function()          here contenet added ajax functionality      </div>       <script type="text/javascript">            $(function(){             $('._div_change').addclass('.div_class');                  });      </script>     </body>   loading first time & class added fn() |only div innerhtml modified ajax ***                                              |       <div class="_div_change div_class">     | <div class="_div_change">        innerhtml elements added successfully|   innerhtml elements altered     </div>                                  | </div>      

your script incomplete, assuming looks this:

$(function(){         $('._div_change').addclass('.div_class'); }); 

...then you're doing there telling jquery run function once when dom loaded (calling $() function shortcut jquery.ready). if want re-run function when update div's contents via ajax, you'll have in success handler on ajax call.

you can give jquery function call whenever ajax call complete, via jquery.ajaxsuccess, may useful.


Comments