tags:

views:

69

answers:

2

Is there a nicer way in jQuery to do this ?

$(":text").each(function() {
   if (this.style.visibility == "visible") {
      ...
   };
});
+4  A: 

yes:

$(":text:visible").each(function() {
   ...
});

UPDATE Since jQuery this doesn't work anymore: details.

frunsi
Note that this is probably what the OP wants, but not the literal translation (since they're using `visibility` and not `display`).
Nick Craver
@Nick, in that case, `$(":text:visible, :text:not(':hidden')".each(..` would work.
Jim Schubert
None of the options above works for me :( Note that I set the "visibility" like this: $("#myid").attr("style", "visibility: hidden"); What I see is all elements including the hidden ones...
Misha Moroshko
For setting visibility you should use: $("#myid").css("visibility","hidden"). Also note the updated answer..
frunsi
What is the difference between $("#myid").attr("style", "visibility: hidden") and $("#myid").css("visibility","hidden") ?
Misha Moroshko
read the jquery documentation or post another new question
frunsi
A: 

You're looking for the :visible selector:

$(':text:visible')
SLaks