JQuery empty selector

<html>
<head>
<title>jQuery empty example</title>
 
<script type="text/javascript" src="jquery-1.9.1.js"></script>
 
<style type="text/css">
	div{
		padding:8px;
		border:1px solid;
	}
</style>
</head>
 
<body>
 
<h1>jQuery empty example</h1>
 
<div class="div-class1">
	This is div-class1
</div>
 
<div class="div-class2"></div>
 
<div class="div-class3">
	This is div-class3
	<div class="div-class3-1">
		This is div-class3-1
	</div>	
</div>
 
<br/><br/>
 
<button>:empty</button>
 
<script type="text/javascript">
    $("button").click(function () {
      var str = $(this).text();
      $("*").css("background", "yellow");
      $(str).css("background", "red");
    });
</script>
 
</body>
</html>
相關文章
相關標籤/搜索