jQuery .is('input:hidden') function returns true if any input type element is not visible -


you can use jquery .is() function determine if html element of specific type. example,

$(x).is('input:text')  

will return true if x references a

<input type="text'>  

element.

i noticed if make text (or other) input element invisible, use $(x).is('input:hidden'), returns true.

to match

<input type="hidden"> 

elements, must do

$(x).is('input[type=hidden]') 

am missing here, or bug? thought :hidden referred element type, not visibility of element.

here's requisite codepen: https://codepen.io/anon/pen/lzpdaj

first of all, jquery method is, not checking element type, checking against jquery selector - https://api.jquery.com/is/

as selector, in css :hidden match type hidden, same selector has broader meaning in jquery.

from docs - https://api.jquery.com/hidden-selector/

elements can considered hidden several reasons:

  • they have css display value of none.
  • they form elements type="hidden".
  • their width , height explicitly set 0.
  • an ancestor element hidden, element not shown on page.

Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -