前言
jQuery的属性选择器:
$("[href]") | 选取带有 href 属性的元素 |
运用
这个属性选择器可以选择自定义的属性。
<html> <head> <script type="text/javascript" src="./jq/jquery.js"></script> <script type="text/javascript"> $(function(){ $("[cool]").click(function(){ alert(1); }); }); </script> </head> <body> <button type="button" cool="bt">Click me</button> </body> </html>