English 中文(简体)
j Query - 如何选择隐蔽/可观的内容?
原标题:jQuery - How to select hidden/visible elements?
  • 时间:2012-01-11 17:18:31
  •  标签:
  • jquery

I m trying to do multistep form, and I have 5 div s (all of them hidden) The five of them are parts of a form so I can get the first and the last div by doing this

  var first = $("#new").children(":first").next();
  var last = $("#back").prev( div );

"#new" is the id of the form, and "#back" the id of the back button. After click on the NEXT button it shows first.next(); , but it should only work the first time then it should display the next() of the div that is visible.

我怎么能够做到这一点?

增 编

EDIT: I m trying to do this because after I click next on the first div then it shows the second div, and after that the third an so on, but I want to do a function where it automatically detects wich one is visible.

最佳回答

你的问题有点混淆,但如果你想要检查某一要素是否明显,你可以使用<代码>:hidden/code>。 pseudo selectedor:

var first = $("#new").children(":first").nextAll( :hidden );

仅找到可见的要素:

var first = $("#new").children(":first").nextAll( :visible );

http://api.jquery.com

http://api.jquery.com

http://jsfiddle.net/v8fKc/“rel=“nofollow” http://jsfiddle.net/v8fKc/。

通知一使用<代码>>.nextAll(),而不是.next(),因为后者只考虑下一个单一要素,而前者则研究在进行根本选择后产生的所有可操作元素。

rel=“nofollow”http://api.jquery.com/nextall。

问题回答
if ($( #theid:visible ).length > 0)
     console.log( I Am Visible );
else
     console.log( I Am Not Visible );

give:

 $(this).is( :visible );




相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签