Javascript 如何获取点击按钮的类(索引)序列号
我需要帮助 HTMLJavascript 如何获取点击按钮的类(索引)序列号,javascript,css,html,web,Javascript,Css,Html,Web,我需要帮助 HTML <input type="button" onclick="myFunction()" class="myButton" value="Button1"> <input type="button" onclick="myFunction()" class="myButton" value="Button2"> <input type="button" onclick="myFunction()" class="myButton" value="
<input type="button" onclick="myFunction()" class="myButton" value="Button1">
<input type="button" onclick="myFunction()" class="myButton" value="Button2">
<input type="button" onclick="myFunction()" class="myButton" value="Button3">
<input type="button" onclick="myFunction()" class="myButton" value="Button4">
试试这个
var数组=document.getElementById('wrapperDiv');
for(变量i=0,len=array.children.length;i
元素索引是:
JS:function myFunction(){var button=document.getElementsByClassName(“myButton”);var index;for(var i=0;i