代码之家  ›  专栏  ›  技术社区  ›  curly_brackets

jquery悬停父级影响子级

  •  1
  • curly_brackets  · 技术社区  · 15 年前

    我很好奇,当你徘徊在父母身上时,你是如何瞄准一个孩子的?

    我在CSS中的方式:

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

    如何在jquery中执行此操作? “.medarbejdere.info SPAN.kontaktino”信息 是我的父母。我想要 $(此) 做我的孩子。

    var navDuration = 150; //time in miliseconds
      var forstoer = "150px";
    
      $('.medarbejdere .info span.kontaktinfo').hover(function() {
          $(this).animate({ 'right' : "+="+forstoer }, navDuration);            
      }, function() {
          $(this).animate({ 'right' : "-150px" }, navDuration);
        });
    

    事先谢谢你…

    1 回复  |  直到 15 年前
        1
  •  3
  •   tvanfosson    15 年前

    使用 $(this).children() .

    前任:

    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); 
    });