jquery hover function in views template (drupal 6) I have a views template called: views-view-fields--video--block-1.tpl.php

Inside that file i have:

&lt;script type="text/javascript"&gt;
  $(document).ready(function() {
    $('.last-vid-poster').hover(function() {
        $(this).parents('.last-vid-block').find('a.play_button').fadeIn('slow');
      }, function() {
        $(this).parents('.last-vid-block').find('a.play_button').fadeOut('slow');
      }
    );
  });
&lt;/script&gt;

&lt;?php

print '&lt;div class="last-vid-block"&gt;';

print '&lt;div style="float: left; margin-right: 8px;"&gt;'. $fields['field_video_embed']-&gt;content.'&lt;/div&gt;';

print '&lt;h3 class="video-block"&gt;'. $fields['title']-&gt;content .'&lt;/h3&gt;';

$hover_play = l('&lt;img src="/' . path_to_theme() . '/img/play-button.png" /&gt;', 'node/' . $row-&gt;nid, array('attributes' =&gt; array('class' =&gt; 'play_button', 'style' =&gt; 'display: none'), 'html' =&gt; true));

print $hover_play;

print '&lt;/div&gt;'; // vgrid

?&gt;


As you can see in my JS code at the top of the template, i'm printing $hover_play when user hovers over .last-vid-block .imagecache object, so it fades In then fades Out, that works, yeah.

But the problem is -> i have in that views block 4 nodes with that markup, so when i hover over just one .last-vid-block .imagecache that $hover_play shows on all 4 objects... How to separate them - if i hover just 1st object $hover_play shows only at 1st object etc... 
Thanks in advance!

ATTENTION! Edited js code at the top! It works as intended, is there any erros in that code?
The original issue was that you were targeting all play buttons at once with your JS, the second problem that came up in the comments below is that your play button is on top of your .imagecache object and your .play_button is taking away the mouse focus, thus firing "hover out"

Try this:

&lt;script type="text/javascript"&gt;
  $(document).ready(function() {
    $('.last-vid-block').hover(function() {
      $(this).find('a.play_button').fadeIn('slow');
    }, function() {
        $(this).find('a.play_button').fadeOut('slow');
      }
    );
  });
&lt;/script&gt;


The downside to this, however, is that if you hover over the title on the right side (outside of the .imagecache) object, your still going to get the fade in/out effect triggered...

If that is not what you want then you could try altering the template:

&lt;script type="text/javascript"&gt;
  $(document).ready(function() {
    $('.last-vid-poster').hover(function() {
      $(this).find('a.play_button').fadeIn('slow');
    }, function() {
        $(this).find('a.play_button').fadeOut('slow');
      }
    );
  });
&lt;/script&gt;

&lt;?php

print '&lt;div class="last-vid-block"&gt;';

print '&lt;div class="last-vid-poster" style="float: left; margin-right: 8px;"&gt;';

print $fields['field_video_embed']-&gt;content;

$hover_play = l('&lt;img src="/' . path_to_theme() . '/img/play-button.png" /&gt;', 'node/' . $row-&gt;nid, array('attributes' =&gt; array('class' =&gt; 'play_button', 'style' =&gt; 'display: none'), 'html' =&gt; true));

print $hover_play;

print '&lt;/div&gt;';

print '&lt;h3 class="video-block"&gt;'. $fields['title']-&gt;content .'&lt;/h3&gt;';


print '&lt;/div&gt;'; // vgrid

?&gt;