child")举例说明...">
美文网首页
层次选择器说明

层次选择器说明

作者: crocodile_b | 来源:发表于2016-01-20 14:45 被阅读47次

jQuery的层选择器$("ancestor descendant")和$("parent>child")举例说明

<div>This is <strong>very</strong> important.</div>
<div>This is <em>really <strong>very</strong></em> important.</div>

以上是html。运行后在浏览器里是看到


1.JPG

这样的样式,为了容易看到效果,我们不妨就尝试用添加css颜色来试一下

如果运行

$("div strong").css("color","red");

就是把div的后代元素strong变为红色。运行后是


2.JPG

如果运行

$("div>strong").css("color","blue");

就是把div的子元素strong变为蓝色。运行后是

3.JPG
  • $("ancestor descendant")
    表示所有的ancestor以下的descendant
  • $("parent>child")
    表示当且仅当child紧跟着parent的时候

相关文章

  • css3选择器

    CSS3选择器分类 层次选择器,常用的选择器| 选择器|类型|说明 ||--|--|--|--||E F |后代...

  • 层次选择器说明

    jQuery的层选择器$("ancestor descendant")和$("parent>child")举例说明...

  • jQuery选择器

    jQuery选择器可以分为基本选择器、层次选择器、过滤选择器和表单选择器。 1、基本选择器 2、层次选择器 3、过...

  • CSS伪类伪元素

    CSS选择器大致可以分成5类:基本选择器,层次选择器,属性选择器,伪类,伪元素。基本,层次,属性选择器比较容易理解...

  • css选择器

    id选择器,class选择器,层次选择器,后代选择器,标签选择器,元素选择器。

  • 第2章 CSS3选择器-2

    2.3 层次选择器 层次选择器通过HTML的DOM元素间的层次关系获取元素,其主要的层次关系包括后代、父子、相邻兄...

  • css选择器

    css选择器】 1.css属性选择器 2.css伪类选择器 3.css层次选择器

  • jQuery相关复习

    jQuery相关 jQuery选择器 参考手册 基本选择器 层次选择器 过滤选择器 可见性过滤选择器 属性过滤选择...

  • jQuery选择器

    基本选择器 层次选择器 过滤选择器 基本过滤选择器 内容过滤选择器 可见性过滤选择器 属性过滤选择器 子元素过滤选...

  • jQuery基础知识

    一、jQuery选择器 1. 基本选择器 2. 层次选择器 3. 过滤选择器 3.1 基本过滤选择器 3.2 内容...

网友评论

      本文标题:层次选择器说明

      本文链接:https://www.haomeiwen.com/subject/cpllkttx.html