Search code examples
javascripthtmlyui

Set value in html input not work


i wanted to fill the first form on yahoo registration automatically. for example when i click and choose inspect element on this page and change firstname input from

<input type="text" title="First Name" name="firstname" id="firstname" value="" size="32" maxlength="32" class="fieldValInit" autocomplete="off" aria-required="true" tabindex="1">

to

<input type="text" title="First Name" name="firstname" id="firstname" value="salam" size="32" maxlength="32" class="" autocomplete="off" aria-required="true" tabindex="1">

I do not see any changes on the page. Why?


Solution

  • Because of the placeholder you don't see the change. You can use:

    document.getElementById('firstname').value = 'foo';
    

    in the browser's console and you'll see the first name changed to foo.