JQuery - * 选择器

1. #('*') 选择所有元素。

2. #('div > *')选择所有的div元素

<html>
<head>
<title>jQuery universal example</title>
 
<script type="text/javascript" src="jquery-1.9.1.js"></script>
 
<style type="text/css">
	div{
		padding:8px;
	}
</style>
</head>
 
<body>
 
<h1>jQuery universal example</h1>
 
<div class="div-class1">
	This is div-class1
	<div class="div-class2">
		This is div-class1
	</div>
	<div class="div-class3">
		This is div-class3
	</div>
</div>
 
<br/><br/>
<button>*</button>
<button>div > *</button>
<button id="refresh">Refresh</button>
 
<script type="text/javascript">
    $("button").click(function () {
       var str = $(this).text();
       $(str).css("border", "1px solid #ff0000");
    });
 
    $('#refresh').click(function() {
    	location.reload();
    });
 
</script>
 
</body>
</html>



你可能感兴趣的:(JQuery - * 选择器)