LoginSignup
0
1

More than 3 years have passed since last update.

【メモ】要素が持つ子要素のindex番号を取得する

Last updated at Posted at 2019-04-04

JQueryだと簡単なのにね!

%ul{onclick: 'edf5(event)'}
  %li パンドラ
  %li セイレーン
  %li エピメテウス
function edf5(e) {
  console.log(Array.prototype.indexOf.call(e.target.parentNode.querySelectorAll("li"), e.target));
};
0
1
2

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
1