admin管理员组文章数量:1313133
How can I hide a div with no ID? I have an application which creates few stickies. Some of them have no ID and some of the do have. How can I hide the ones with no ID?
The position is not always the same.
This is what I get in the HTML where I want to hide the last one.
Is it possible I can hide the one with no ID? Note that the rest which have ID's, is a number generated randomly.
Thanks alot.
How can I hide a div with no ID? I have an application which creates few stickies. Some of them have no ID and some of the do have. How can I hide the ones with no ID?
The position is not always the same.
This is what I get in the HTML where I want to hide the last one.
Is it possible I can hide the one with no ID? Note that the rest which have ID's, is a number generated randomly.
Thanks alot.
Share Improve this question asked Sep 27, 2011 at 17:58 jQuerybeastjQuerybeast 14.5k39 gold badges119 silver badges198 bronze badges 1-
Will there only be a single div with class
sticky
that needs to be hidden? – Larsenal Commented Sep 27, 2011 at 18:01
2 Answers
Reset to default 6Try this:
$("div.sticky:not([id])").hide();
The main idea is to use :not([id])
selector with element selector.
fiddle: http://jsfiddle/57uQ8/
http://sandbox.phpcode.eu/g/d2956/2
<script>
$(function(){
$("div.sticky").each(function(b){
if (!$(this).attr('id')){
$(this).hide();
}
});
});
</script>
will probably do it, assuming you want to show ONLY divs with no IDS and divs with class sticky
本文标签: javascriptjQuery Hide div with no IDStack Overflow
版权声明:本文标题:javascript - jQuery: Hide div with no ID - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741921706a2405040.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论