jQuery :submit 选择器
实例
使用 type="submit" 选择 <input> 和 <button> 元素:
<!DOCTYPE html><html><head><script src="https://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script><script>$(document).ready(function(){$(":submit").css("background-color", "red");});</script></head><body><form action="">名称: <input type="text" name="user"><br>密码: <input type="password" name="password"><br><button type="button">无用的按钮</button><input type="button" value="另一个无用按钮"><br><input type="reset" value="重置"><input type="submit" value="提交"><br></form></body></html>
定义与用法
:submit 选择器选择 type=submit 的 button 和 input 元素。
如果 button 元素没有定义的类型,大多数浏览器会将其用作 type=submit 的按钮。
提示: 使用 input:submit 作为选择器将无法选择到 button 元素。
语法
$(":submit")