0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

:hasの備考 孫要素指定の仕方

Last updated at Posted at 2023-11-28

結論

孫要素の指定も:has()のみでいい


記事を書いた理由

:has()について勘違いしていました。
同じ人のために記事を書きます。


次のような構造の時、

 クラスA
   クラスB
     クラスC
         <タグF クラスD id="1234">

『タグFにid=1234を持つクラスA』を指定したいとします。

その場合:hasを使いますが、自分の間違った書き方がこちらです。

.A:has(.B:has(.C:has(F[id="1234"])))

正しい書き方はこちら

.A:has(F[id="1234"])

Javaの癖でなんでもかんでも入れ子にすればいいと思っていました。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?