<!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 src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("[id]").css("color","blue");
})
</script>
</head>
<body>
<h1 id="main_header">实验element</h1>
<p class="intro">这是个带class的p1</p>
<p>p标签2</p>
<p>p标签3</p>
<h3 id="sub_header">h3</h3>
<div id="choose">
这是个div
<ul>
<li>li1</li>
<li>li2</li>
<li>li3</li>
</ul>
</div>
</body>
</html>
效果图:
<!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 src="jquery.js"></script>
<script type="text/javascript">
$(function(){
$("body [id!=main_header]").css("color","red");
})
</script>
</head>
<body>
<h1 id="main_header">实验element</h1>
<p class="intro">这是个带class的p1</p>
<p>p标签2</p>
<p>p标签3</p>
<h3 id="sub_header">h3</h3>
<div id="choose">
这是个div
<ul>
<li>li1</li>
<li>li2</li>
<li>li3</li>
</ul>
</div>
</body>
</html>
效果图:
<!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 src="jquery.js"></script>
<script type="text/javascript">
$(function(){
$("[id$=header]").css("background","yellow")
})
</script>
</head>
<body>
<h1 id="main_header">实验element</h1>
<p class="intro">这是个带class的p1</p>
<p>p标签2</p>
<p>p标签3</p>
<h3 id="sub_header">h3</h3>
<div id="choose">
这是个div
<ul>
<li>li1</li>
<li>li2</li>
<li>li3</li>
</ul>
</div>
</body>
</html>
效果图:
定义和用法
[attribute$=value] 选择器选取每个带有指定属性且以指定字符串结尾的元素。
语法
$("[attribute$=string]")
参数 | 描述 |
---|---|
attribute | 必需。规定要查找的属性。 |
string | 必需。规定属性值以其结尾的字符串。 |