jquery中的选择器01
<!doctype html>
<html>
<head>
<meta charset="gb2312">
<title>部长练习jqurey</title>
<script src="js/jquery-1.11.1.min.js"></script>
<script>
$(document).ready(function(e) {
// 选择div标签中含有id的div
$('div[id]').css('font-size','50px');
//选择div标签中class=aa的div
$('div[class=aa]').html('1111111111111111');
//选择div标签中class=以nav—开头的div
$('div[class^=nav-]').css('color','red');
});
</script>
</head>
<body>
<div id="ddd">hello</div>
<hr>
<div class="aa">ok</div>
<div class="aa">ff</div>
<hr>
<div class="nav-left">menu1</div>
<div class="nav-right">menu1</div>
<div class="nav-center">menu1</div>
<div class="ok-nav">menu1</div>
</body>
![]()
<html>
<head>
<meta charset="gb2312">
<title>部长练习jqurey</title>
<script src="js/jquery-1.11.1.min.js"></script>
<script>
$(document).ready(function(e) {
// 选择div标签中含有id的div
$('div[id]').css('font-size','50px');
//选择div标签中class=aa的div
$('div[class=aa]').html('1111111111111111');
//选择div标签中class=以nav—开头的div
$('div[class^=nav-]').css('color','red');
});
</script>
</head>
<body>
<div id="ddd">hello</div>
<hr>
<div id="myd2">header-div</div>
<hr>
<div class="aa">ok</div>
<div class="aa">ff</div>
<hr>
<div class="nav-left">menu1</div>
<div class="nav-right">menu1</div>
<div class="nav-center">menu1</div>
<div class="ok-nav">menu1</div>
</body>
</html>
网页效果如图所看到的: