2013年4月12日 星期五

Selecting Input Elements

$(':input') selects all input elements including:

input, select, textarea, button, image, radio and more.

$(:input') and $(input') are different, the second one will only select INPUT element but not others

 

Demo Example:

image

image

image

image

image

image

image

image

image

Other Notes:

1. More efficient way to select is like $('#form1 :input') with ID selector

2. There are more selectors for form elements, can refer to below

http://api.jquery.com/category/selectors/

:button Selector 

Selects all button elements and elements of type button.

 

:checkbox Selector 

Selects all elements of type checkbox.

 

:checked Selector

Matches all elements that are checked.

 

:hidden Selector

Selects all elements that are hidden.

 

:image Selector

Selects all elements of type image.

 

:radio Selector

Selects all elements of type radio.

 

:selected Selector

Selects all elements that are selected.

沒有留言:

張貼留言