Reputation: 2032
Example html:
<input type="text" name="nhdd9812"></input>
<input type="text" name="ndf4e"></input>
<input type="text" name="018y3"></input>
<input type="text" name="nsiohf8"></input>
How can I by javascript, set all text-inputs on the page to one value? (Without knowing their ids/names). Lets say "1" for examples sake.
Is this possible without a framework?
Upvotes: 0
Views: 30
Reputation: 104785
You can do:
var inputs = document.querySelectorAll("input:text");
for (var i = 0; i < inputs.length; i++) { inputs[i].value = 1; }
Upvotes: 2