上一章:MongoDB Java | 下一章:MongoDB PHP |
<!DOCTYPE html>
<html>
<head>
<script src="//libs.baidu.com/jquery/1.10.2/jquery.min.js">
</script>
<script>
$(document).ready(function(){
$("div span").css("background-color","yellow");
});
</script>
</head>
<body>
<h2>What will $("div span") select?</h2>
<h4>This div element has two descendants, p and span:</h4>
<div style="border:1px solid black;padding:10px;">
<p>This is a paragraph.</p>
<span>This is a text inside a span.</span>
</div>
<h4>This div element has also two descendants, p and span:</h4>
<div style="border:1px solid black;padding:10px;">
<p>This is a paragraph. <span>This is a span element, inside the paragraph.</span></p>
</div>
</body>
</html>
("parent descendant") 选择器选取指定元素的后代的所有元素。
元素的后代可以是元素的第一代、第二代、第三代等等。
参数 | 描述 |
---|---|
parent | 必需。规定要选取的父元素。 |
descendant | 必需。规定要选取的(指定父元素的)后代元素。 |