gpt4 book ai didi

Jquery 查找 - 仅可见

转载 作者:行者123 更新时间:2023-12-03 22:48:07 27 4
gpt4 key购买 nike

我想检查 div 是否包含类为“error”的子级,但条件是错误类显示不等于无。 (意味着错误类必须可见。

如何更改我的以下代码:

 $(".related_field").each(function(){
var $widthAdj = $(this).find(".autoDiv");
if($(this).find(".error").length == 0){ //MUST BE VISIBLE "ERROR" CLASS ONLY
$widthAdj.css("height","48px");
} else {
$widthAdj.css("height","63px");
}
});

最佳答案

你的意思是这样吗?使用:visible选择器:

if($(this).find(".error:visible").length == 0)
$widthAdj.css("height","48px");
} else {
$widthAdj.css("height","63px");
}

关于Jquery 查找 - 仅可见,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15655085/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com