Support » Fixing WordPress » jquery image hover homepage loop

  • Resolved lbens


    hey.. so i’ve got this jquery hover working on my homepage post loop thumbnails;

    except when i rollover one image it is applying the effect to all of them. how can i add an identifier to each thumbnail, or solve it in another way?
    ANy hints would be so appreciated 🙂
    ps.i’m fairly new to jquery/javascript.

    javascript function
    <script type=’text/javascript’>
    $(‘.slidethumb’).hover(function() {
    $(‘.slidethumb img’).stop(true,true).fadeTo(400, 0.45);
    }, function() {
    $(‘.slidethumb img’).stop(true,true).fadeTo(400, 1);

    homepage code
    <div class=”slidethumb”>
    <img><?php get_the_image( array( ‘custom_key’ => array( ‘thumbnail’ ), ‘default_size’ => ‘thumbnail’, ‘width’ => ‘310’, ‘height’ => ‘150’ ) ); ?></img>
    <div class=”slidedesc”>
    <p><?php the_excerpt(); ?></p>


Viewing 3 replies - 1 through 3 (of 3 total)
  • Took me a bit to find out how to do this when I was starting out with jQuery too.

    Use the $(this) identifier to specify the specific element the actions are happening with, then use .find or .children to find child elements within it.

    Try this javascript:

    	$('.slidethumb').hover(function() {
    		$(this).find('img').stop(true,true).fadeTo(400, 0.45);
    	}, function() {
    		$(this).find('.slidethumb img').stop(true,true).fadeTo(400, 1);

    $(this) will perform the action on the instance of .slidethumb the user is currently interacting with.

    Also, use the code button in the Message box to make code a little more readable :]

    Let me know if this works for you!

    perfect! thanks so much.. and clearly explained too 🙂

    Awesome! Go ahead and mark this as resolved then?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘jquery image hover homepage loop’ is closed to new replies.