myhrmans
myhrmans

Reputation: 35

Selecting a specific class with jQuery when you have more then one with the same name

I'm creating an image gallery that is outputting the latest uploaded image using PHP:

while($row = mysqli_fetch_array($result))
{
echo  "<div class='ram-bild'>
<div class='nailthumb-container square'>
<a href='bigpicture.php?id=" . $row['pic_name']  . "'><img src=upload/thumb/" .$row['pic_name']  . "></img></a>
</div>
</div>";
}

$result just gets the id from my table.

Now I want to use jQuery to show a text over the image when you hold your mouse on it.

Like this:

No mouse: Mouse over: http://piclair.com/data/0ooqy.jpg But since all images have the same class how would I pull this of with jQuery?

Upvotes: 0

Views: 35

Answers (1)

tymeJV
tymeJV

Reputation: 104785

Use an instance of this

$(".ram-bild").hover(function() {
    $(this)... //targets the above element on mouseenter
}, function() {
    $(this)... //targets above element on mouseleave
});

Upvotes: 2

Related Questions