Javascript examples for Array Operation:Array Element
Repack array after loop
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){/*ww w. j ava 2 s .c o m*/ var btn = document.getElementsByClassName('btn'); var a = []; for(i=0; i<btn.length; i++){ a.push(btn[i].value); console.log(a[i]); } console.log(a[a.indexOf("Windows")]); } </script> </head> <body> <input class="btn" type="submit" value="Windows"> <br> <input class="btn" type="submit" value="Linux"> </body> </html>