jquery中 $.expr使用实例介绍


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> new document </title>
<meta content="editplus" />
<meta content="" />
<meta content="" />
<meta content="" />
</head>

<body>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title></title>
<link type="text/css" href="" />
<script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script>
<link type="text/css" href="https://www.jb51.net/demos.css" />
<script type="text/javascript">
$(function() {
//初始测试数据
var init=function(){
$("#con1").add("#con3").data("key","10001");
};
init();
var select="mytest";
var;
//定义一个新选择器
$.expr[ ":" ][ select ] = function( elem ) {
return !!$.data( elem, name );
};
//使用
$("div:mytest").each(function(){
alert(this.id);//结果:con1 con3
})
});
</script>
</head>
<body>
<div></div>
<div></div>
<div></div>
</body>
</html>

</body>
</html>

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wgpdpg.html