jQuery属性选择器,可以选择自定义的内容。

前言

     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>

猜你喜欢

转载自blog.csdn.net/a4171175/article/details/80451316