【发布时间】:2018-10-20 04:22:50
【问题描述】:
当折叠链接具有 aria-expanded="true" 时,我正在尝试向我的父 div 添加一个类,但没有发生任何事情。
<div class="info-tab col-xl-3">
<div class="info-img">
<?php the_post_thumbnail(); ?>
</div><!-- .news_img -->
<a data-toggle="collapse" href="#collapse-<?php the_ID(); ?>" class="info-title" role="button" aria-expanded="false" aria-controls="collapse-<?php the_ID(); ?>">
<?php the_title(); ?>
</a>
</div>
和 jquery
jQuery(function($){
$(function() {
$('.info-title[aria-expanded="true"]').closest('.info-tab').addClass('no-border');
});
});
我还试图通过将 .info-title[aria-expanded="true"] 更改为 a[aria-expanded="true"] 并最接近父母来使其工作,但它没有工作。
【问题讨论】:
-
在 OP 中值为 false
-
@guradio 感谢您为我指出这一点。
标签: javascript jquery