How to get this to load last?

 <script type="text/javascript">
  jQuery(document).ready(function(){
   jQuery("div.domTip_tipBody").mouseover(function(){
   jQuery("#yyy a.tippy_link").css("background-color","yellow");});  

   jQuery("div.domTip_tipBody").mouseout(function(){
   jQuery("#yyy a.tippy_link").css("background-color","red");
 }); 
 });  
 </script>

It is running before “div.domTip_tipBody” is being run (which is generated by a shortcode) so nothing happens.

I have tried:

<script src="https://wordpress.stackexchange.com/questions/47618/script.js" type="text/javascript" defer="defer"></script>

in my header.php before

</head> 

but it doesn’t help.

Have seen “window.onload =” but not sure how to apply it.

Any insight is appreciated.

Thanks

5 Answers
5

add_action('wp_footer','myscript_in_footer');
function myscript_in_footer(){
?>
<script type="text/javascript">
  jQuery(document).ready(function(){
   jQuery("div.domTip_tipBody").mouseover(function(){
   jQuery("#yyy a.tippy_link").css("background-color","yellow");});  

   jQuery("div.domTip_tipBody").mouseout(function(){
   jQuery("#yyy a.tippy_link").css("background-color","red");
 }); 
 });  
 </script>
<?php
}

Leave a Reply

Your email address will not be published. Required fields are marked *