:empty selector not working in css

后端 未结 2 1229
故里飘歌
故里飘歌 2020-12-29 06:37

i used :empty selector in .error class. the problem is that even when there is no content inside the div with class of error, the error class is n

2条回答
  •  -上瘾入骨i
    2020-12-29 07:13

    it is because

    (demo) is not empty, it has a text node as the child.

    :empty

    The :empty pseudo-class represents any element that has no children at all. Only element nodes and text (including whitespace) are considered. Comments or processing instructions do not affect whether an element is considered empty or not.

    Try

    Demo: Fiddle

提交回复
热议问题