gpt4 book ai didi

javascript - 从 getElementsByClassName 集合获取索引值

转载 作者:行者123 更新时间:2023-11-29 14:48:18 24 4
gpt4 key购买 nike

<分区>

如何获取getElementsByClassName集合的索引值。

function clickSchedule(){
var t = document.getElementsByClassName("table")
for(i=0; i<=t.length; i++)
{
t[i].onclick= function() {

// get the index value of the node when clicked something like this
// alert(t[i].index)
// already tried alert(t[i]) returning undefined.
// already tried alert(t.item(i)) returning NULL.
};
}
}
window.onload = function(){
clickSchedule();
};

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com