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?

【JavaScript】兄弟要素を取得する方法

Posted at

直前の要素を取得する

previousElementSiblingを使用するとその要素の直前の兄弟要素を取得できます。

const previousSibling = elem.previousElementSibling;
console.log("prevSibling", previousSibling);

直後の要素を取得する

nextElementSiblingを使用するとその要素の直後の兄弟要素を取得できます。

const nextSibling = base.nextElementSibling;
console.log("nextSibling", nextSibling);

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?