I have a loop in php which echo out these divs:

<div class="nyhed">
 <p class="nyheds_dato_p" style="color:#900;">'.$pub_date[1].'/'.$pub_date[2].'/'.$pub_date[0].'</p>
 <p class="nyhed_p">'.substr($teaser, 0, 55).'..</p>
 <a href="'.$url.'" class="nyheds_link">'.$link_navn.'</a>            
</div>';

When ever a link is hovered, i am adding an animation to change the background color of the div class="nyhed".

As it is now, all the divs are animated..How do i only add the jquery function the specific div class="nyhed" belonging to the link being hovered?

This is what i have:

$(document).ready(function(){
$(".nyheds_link").hover(function() {
$(".nyhed").animate({ backgroundColor: "#DDD" }, 800);},function() 
{
    $(".nyhed").animate({ backgroundColor: "#f5f5f5" }, 300);
});
});

Do I need to add: .each and then .find the parent class="nyhed"? And how can I achieve that....

All the best,

Klemme

It works this way, but thanks anyways :-)

$(document).ready(function(){
  $(".nyheds_link").hover(function() {
  $(this).parent().animate({ backgroundColor: "#DDD" }, 800);},function() 
  {
      $(this).parent().animate({ backgroundColor: "#f5f5f5" }, 300);
  });
});
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.