I tried with the original answer without success, so I use this:
var elements = document.querySelectorAll("input[type=button]");
Example:
var elements = document.querySelectorAll("input[type=button]"); for(var i = 0, len = elements.length; i < len; i++) { console.log("Button: " + elements[i].id); }
<input type="button" id="alfa" value="alfa"> <input type="button" id="beta" value="beta"> <input type="button" id="gamma" value="gamma"> <input type="button" id="omega" value="omega">
source share