![](/img/trans.png)
[英]How can I check if an element with a changeable child element contains an array property with a certain value?
[英]how to select a child of an element with a certain property
有人知道如何选择具有display ==块的元素的所有子元素吗? 我找到了允许过滤器的jquery children()函数,但是我还没有弄清楚如何过滤style.display == block?
$('#div_id').children('div.style.display == block')
您可以在jQuery中使用filter()
来实现自定义过滤功能
$('#div_id') .children() // get all children .filter(function() { // filter with your custom condition here return this.style.display == 'block' }).css('color', 'red');
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <div id="div_id"> <div style="display:block">1</div> <div style="display:inline">1</div> <div style="display:inline-block">1</div> </div>
$('#div_id').children('div[style="display:block"]');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.