37-解决方案
2.9.2 解决方案
jQuery提供了一组用于这个极端目的的实用过滤器,如表2-1所示。
| jQuery选择器语法 | 选择什么 |
| :----- | :----- | :----- | :----- |
| :text | <input type="text" /> |
| :password | <input type="password" /> |
| :radio | <input type="radio" /> |
| :checkbox | <input type="checkbox" /> |
| :submit | <input type="submit" /> |
| :image | <input type="image" /> |
| :reset | <input type="reset" /> |
| :button | <input type="button" /> |
| :file | <input type="file" /> |
| :hidden | <input type="hidden" /> |
举个例子,如果需要选择所有文本输入控件,可以简单地使用下列代码:
jQuery(':text');`
还有一个 :input 过滤器,可以选择所有的 input 、 textarea 、 button 和 select 元素。