最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Find first invisible block by jQuery - Stack Overflow

programmeradmin3浏览0评论

HTML:

<div style="display:block">Text</div>
<div style="display:block">Text</div>
<div style="display:none">Text</div>
<div style="display:none">Text</div>
<div style="display:none">Text</div>

How do I find first invisible block and make it visible?

If there is no invisible block, do nothing.

HTML:

<div style="display:block">Text</div>
<div style="display:block">Text</div>
<div style="display:none">Text</div>
<div style="display:none">Text</div>
<div style="display:none">Text</div>

How do I find first invisible block and make it visible?

If there is no invisible block, do nothing.

Share Improve this question asked Mar 4, 2011 at 16:16 JamesJames 43.7k54 gold badges137 silver badges163 bronze badges
Add a ment  | 

3 Answers 3

Reset to default 12
$('div:hidden:first').show();
  • div the element-selector[docs]

  • :hidden the hidden-selector[docs]

  • :first the first-selector[docs]

Use this:

$('div:hidden:first').show();

jQuery has the :visible and :hidden selectors:

$('#wrapperContainer > div:hidden:first').show();

(Remend a wrapper container because if you just do 'div:hidden:first' it will get the first hidden div on the page, which probably isn't what you want)

发布评论

评论列表(0)

  1. 暂无评论