简体   繁体   English

使用 javascript 查找 div 标签显示属性为 none 或 block 或 undefined

[英]using javascript find div tag display property is none or block or undefined

using that code i am able to find tag display propery but i want to get all the tag which have their display property none.Give me the result using javascript or jquery使用该代码我能够找到标签显示属性,但我想获取所有没有显示属性的标签。使用 javascript 或 jquery 给我结果

document.getElementById('MSO_ContentTable').style.display document.getElementById('MSO_ContentTable').style.display

MSO_ContentTable is an id of div tag MSO_ContentTable是 div 标签的 id

$('div').filter(function() {
    return $(this).css('display') == 'none'; //or whatever you want to filter.
})

See it in action .看到它在行动

$(':hidden')

That should do just fine for you.那应该对你很好。

Using jQuery you can try the below code to find all the elements which are hidden on the page使用 jQuery 您可以尝试以下代码来查找页面上隐藏的所有元素

$("*").is(":hidden").not("input:hidden");

If a jquery solution is okay you could do:如果 jquery 解决方案没问题,您可以这样做:

     $('*:not(:visible)')

this returns a collection of all non visible objects in the dom.这将返回 dom 中所有不可见对象的集合。

These are elements that:这些元素:

  • They have a CSS display value of none.它们的 CSS 显示值为 none。
  • They are form elements with type="hidden".它们是 type="hidden" 的表单元素。
  • Their width and height are explicitly set to 0.它们的宽度和高度明确设置为 0。
  • An ancestor element is hidden, so the element is not shown on the page祖先元素被隐藏,因此该元素不会显示在页面上

You could filter out only those with "display:none" by iterating on them您可以通过迭代仅过滤掉带有“display:none”的那些

Try this code: $("#MSO_ContentTable").css("display","none");试试这个代码: $("#MSO_ContentTable").css("display","none"); Using Jquery, All document by id "MSO_ContentTable" is Gone....使用 Jquery,ID 为“MSO_ContentTable”的所有文档都已消失......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM