jquery combine this and class selector

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
invisibled
Forum Contributor
Posts: 112
Joined: Sun Apr 29, 2007 3:35 pm
Location: New Westminster

jquery combine this and class selector

Post by invisibled »

pickle | Please use [ code=php ], [ code=text ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: Posting Code in the Forums to learn how to do it too.


hey ya'll

i am trying to to write a script that will detect a hover over the div "module" and then fade in the div "info" inside "module". I am using jquery, here is what i have.

Code: Select all

 
$(".module").hover(
     function(){$(this $(".info")).fadeIn("fast");}, 
     function(){$(this).fadeOut("fast");}
);
 
The problem is, using this (to target the specific module) and then using .info. jquery doesnt seem to like that. i can use just "this" and it will fade in and out the entire module, but i need it to fade in and out a div inside module. Any Suggestions, here is my html for module

Code: Select all

 
<div class="module id43">
  <img src="lib/img/tmp/Picture%204.png" alt="" height="359" />
  <div class="info">
    <h2>Matt Saunders</h2>
    <p>Ventosus feugait iriure incassum abluo te sed eros epulae blandit valetudo eu praesent regula. Luptatum lobortis jus nulla os appellatio exerci inhibeo, volutpat iaceo.</p>
                    
    <div class="category">Visual Arts</div>
    <div class="type">Video</div>
  </div>            
</div>
 

pickle | Please use [ code=php ], [ code=text ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: Posting Code in the Forums to learn how to do it too.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: jquery combine this and class selector

Post by pickle »

I've been trying to find a way to combine this and another selector for months - to no avail. The closest I've got is using .children()
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
kaszu
Forum Regular
Posts: 749
Joined: Wed Jul 19, 2006 7:29 am

Re: jquery combine this and class selector

Post by kaszu »

jQuery("expression", "context")
A DOM Element, Document or jQuery to use as context

Code: Select all

$(".module").hover(
    function() {
        $(".info", this).fadeIn("fast");
    },
    function() {
        $(this).fadeOut("fast");
    }
);
Post Reply