Problem selecting specific related elements
Hi all,
Im trying to make a script that shows a certain image when hovering the mouse over a related link.
The way the two are linked is by the images id is the same as the links rel attribute.
My html look like this:
- <div class="pageContent">
- <span id="first-project" class="thumbnails>
- <img alt="" src="link to image">
- </span>
- <a class="project" rel="first-project" href="link">first project</a>
- <span id="second-project" class="thumbnails>
- <img alt="" src="link to image">
- </span>
- <a class="project" rel="second-project" href="link">second project</a>
- </div>
The effect Im trying to achieve is similar to the one used here: link
His script looks like this:
- jQuery(function($) {
$(".project").hover(
function()
{
var rel= $(this).attr("rel");
$("#thumbnails #" + rel).show();
},
function()
{
var rel= $(this).attr("rel");
$("#thumbnails #" + rel).hide();
}
);
So my question is really, how do I apply the same effect to my html?
Im really new to jQuery so would love some help here.
Peter