input - Change form value= attribute with Javascript -


i need simple javascript change value= attribute 2 when page loaded.

<input type="number" step="1" min="1" name="quantity" value="1" title="qty" class="input-text qty text"> 

addeventlistener('load', function() {     document.getelementsbyclassname('qty')[0].value = 2; }); 
  1. you first add event listener load event, runs after page's loaded
  2. within event listener's callback function, select element. in script, select class qty, since class seemed specific of three. should add id attribute input accurately select though.
  3. you first result, @ index [0], , set value 2.

Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -