:reset 选择器
分类:选择器 > 表单选择器 | 选择器 > jQuery扩展选择器
reset selector
描述:选择所有的type="reset"的<input>元素和button元素。
加入于: 1.0
jQuery( ":reset" ):reset等同于[type="reset"]。
其它说明
- 因为
:reset是一个jQuery扩展,并不是CSS规范文档的一部分,使用:reset查询,不能充分利用原生DOM的querySelectorAll()方法来提高性能。要想在现代浏览器中获得更好的性能,请使用[type="reset"]来代替它。
示例
查找所有的type="reset"的<input>。
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>reset demo</title>
<style>
textarea {
height: 45px;
}
</style>
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
</head>
<body>
<form>
<input type="button" value="Input Button">
<input type="checkbox">
<input type="file">
<input type="hidden">
<input type="image">
<input type="password">
<input type="radio">
<input type="reset">
<input type="submit">
<input type="text">
<select>
<option>Option</option>
</select>
<textarea></textarea>
<button>Button</button>
</form>
<div></div>
<script>
var input = $( "input:reset" ).css({
background: "yellow",
border: "3px red solid"
});
$( "div" )
.text( "For this type jQuery found " + input.length + "." )
.css( "color", "red" );
// Prevent form submission
$( "form" ).submit(function( event ) {
event.preventDefault();
});
</script>
</body>
</html>
演示结果