后代元素即层级比当前元素低的所有元素,包括子元素
子元素即层级比当前元素低一级的直接元素
参见 http://blog.sina.com.cn/s/blog_775da6710100vzbr.html
<div>This is <strong>very</strong> important.</div>
<div>This is <em>really <strong>very</strong></em> important.</div>
以上是html。运行后在浏览器里是看到
This is
very important.
This is
really very important.
这样的样式,为了容易看到效果,我们不妨就尝试用添加css颜色来试一下
如果运行$("div strong").css("color","red");就是把div的后代元素strong变为红色。运行后是
This is
very important.
This is
really very important.
如果运行$("div>strong").css("color","blue");就是把div的子元素strong变为蓝色。运行后是
This is
very important.
This is
really very important.