【问题标题】:change attributes of parent elements with jQuery使用 jQuery 更改父元素的属性
【发布时间】:2015-09-16 04:11:01
【问题描述】:

我有一个带有链接的列表,所以,如果我悬停一个链接,我想改变包含链接的背景颜色,它的颜色是哪个类是 '.secctabla' 。

我正在尝试这样做(也使用与 jQuery 集成的 velocity.js),但它不起作用(我也使用 parent(),但它也不起作用):

<tr class="secctabla">
        <td>
          <h3 class="linkCursos"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
          <?php
          $argumentos = array(
            //default to current post
            'post' => 0,
            'before' => '<p class=\"meta\">',
            //this is the default
            'sep' => ' y ',
            'after' => '<p class=\"meta\">',
            //this is the default
            'template' => '%s: %l.'
            );
          ?>

          <?php the_taxonomies($argumentos); ?>
        </td>
        <td> 
          <?php $desc = get_post_custom_values("descripcion");
          if (isset($desc[0])) { ?>
            <p class="small"><?php echo $desc[0]; ?></p>
          <?php } ?>
        </td>
      </tr>

$('.linkCursos a').hover(function() {
    $(this).closest("secctabla").velocity({background: '#000000'});
  })

【问题讨论】:

  • "secctabla" 正在寻找一个不存在的 &lt;secctabla&gt; 元素;您正在寻找具有该类名的元素,并且应该使用:".secctabla"。

标签: jquery velocity.js


【解决方案1】:
  $('.linkCursos a').hover(function() {
    $(this).closest(".secctabla").velocity({rotateZ: "180deg"});
  })

我没有正确指定类。这很好:)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-29
    • 2012-06-19
    • 1970-01-01
    • 2016-06-25
    • 2010-11-02
    相关资源
    最近更新 更多