jQuery 选择器模糊匹配

代码
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
   $(
function(){
       alert($(
"div[id^='T_']").length);
    });
</script>
</head>

<body>
<div id="T_01"></div>
<div id="L_02"></div>
<div id="T_03"></div>
<div id="T_04"></div>
</body>
</html>


alert 弹出值 3;

[attribute^=value]

匹配给定的属性是以某些值开始的元素
 

原文地址:https://www.cnblogs.com/skyblue/p/1892085.html