Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am trying to change:

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
}

To

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

   $.delegate('p','mouseout', function(e){
    jQuery("#yyy a.tippy_link").css("background-color","red");
 }); 
 });  
 </script>
<?php
}

The first one works but the second one dose not.

The reason for the change is that I have elements that are output by a shortcode (e.g "div.domTip_tipBody") that the first function is not reading and it was suggested that the second method might work, but I can not get the second method functioning even with the element 'p'.

Thanks Tim

share|improve this question

1 Answer 1

up vote 0 down vote accepted

Looks like you're missing the jQuery ready function. Try this:

jQuery(document).ready(function($){
    $.delegate('p','mouseover', function(e){ 
        $("#yyy a.tippy_link").css("background-color","yellow");
    }); 

    $.delegate('p','mouseout', function(e){
        $("#yyy a.tippy_link").css("background-color","red");
    }); 
});  

Cheers,

share|improve this answer
    
Thanks for the fast reply dunc. I tried your code still not working. Any other ideas? –  Tim Apr 4 '12 at 0:25
1  
Try substituting the other two occurrences of "jQuery" in the code with "$". There should only be use of "jQuery" once in that snippet. –  tollmanz Apr 4 '12 at 2:10
    
Whoops, yeah! I've edited my post. Try that. –  dunc Apr 4 '12 at 8:52
    
Again thanks for the response dunc, did as you said, sill not working. –  Tim Apr 4 '12 at 12:13
    
Here is what workedjQuery(document).ready(function(){ jQuery("*").delegate("div.domTip_tipBody","mouseover",function(){ jQuery("#yyy a.tippy_link").css("background-color","#392281"); }); jQuery("*").delegate("div.domTip_tipBody","mouseout",function(){ jQuery("#yyy a.tippy_link").css("background-color","transparent"); }); }); –  Tim Apr 4 '12 at 18:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.