开发者

jQuery hover parent affect child

开发者 https://www.devze.com 2022-12-23 14:06 出处:网络
I am curious to know, how you target a child, when hover on a parent? How I would do in CSS: parent:hover child {

I am curious to know, how you target a child, when hover on a parent?

How I would do in CSS:

parent:hover child {
background-color: #FFFFFF;
}

How do you do this in jQuery? ".medarbejdere .info span.kontaktinfo" is my Parent. I would like $(this) to be my child.

var navDuration = 150; //time in miliseconds
  var forstoer = "150px";

  $('.medarbejdere .i开发者_StackOverflownfo span.kontaktinfo').hover(function() {
      $(this).animate({ 'right' : "+="+forstoer }, navDuration);            
  }, function() {
      $(this).animate({ 'right' : "-150px" }, navDuration);
    });

Thank you in advance...


Use $(this).children().

Ex:

var navDuration = 150; //time in miliseconds 
var forstoer = "150px"; 

$('.medarbejdere .info span.kontaktinfo').hover(function() { 
    $(this).children().animate({ 'right' : "+="+forstoer }, navDuration);             
}, function() { 
    $(this).children().animate({ 'right' : "-150px" }, navDuration); 
});
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号