我想用 jquery 检查我的 div 的第一个 child 是否激活了该类。但我无法弄清楚有人可以帮忙吗?
这是我的代码:
$(".popup .title:first-child")
if ($this == .active) {
console.log("class is active");
} else {
console.log("class is not active");
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="popup">
<h3 class="title active"></h3>
<h3 class="title"></h3>
</div>
最佳答案
if ($("div h3:first-child").hasClass(".active")){
console.log("Class is active");
}
关于javascript - 如何检查 div 的第一个 child 是否处于事件状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42765301/