javascript - How to grab all Inputs with Number type -
this question has answer here:
i have several numerical inputs
<input type='number' id='input one'>
scattered throughout html file hundreds of lines of code. have different ids. need set min attribute 0. have other types on inputs on page, can't use
inputs=document.getelementsbytagname();
i need grab inputs type='number'
attribute, , change min attribute. have for-loop rigged , ready, need way grab ones
type='number'
any ideas? help. note: vanilla javascript code only, please.
call getelementsbytagname
, use if
check whether type number
:
var elements = document.getelementsbytagname('input'); for(var i=0; i<inputs.length; i++) { if(inputs[i].type == 'number') { inputs[i].min = 0; } }
Comments
Post a Comment