当前位置:嗨网首页>书籍在线阅读

37-解决方案

  
选择背景色: 黄橙 洋红 淡粉 水蓝 草绿 白色 选择字体: 宋体 黑体 微软雅黑 楷体 选择字体大小: 恢复默认

2.9.2 解决方案

jQuery提供了一组用于这个极端目的的实用过滤器,如表2-1所示。

表2-1 jQuery表单过滤器

| 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 过滤器,可以选择所有的 inputtextareabuttonselect 元素。