There is a code, for a long time I thought why it does not work, but it didn’t solve the problem.

function activate(){ var input = document.getElementById('input'); var div = document.getElementById('div'); div.value=input.value; } <div id="id"></div> <input type="text" id="input" /> <button onClick="activate()"> 

When you click a button, the value from input should be inserted into the div

    3 answers 3

    The mistake is to fix div.value=input.value; where divs need to write not value , but innerHTML

    • Oh really earned! thanks mih. - Ilya Nikolaev
    • one
      I will add that the <b> value </ b> property is available for any form elements (text, select, etc.) - Zowie

    Best of all, everything that relates to forms is implemented as follows:

     form name="myform" input name="myinput" 

    As a result, document.myform.myinput.value .

    • and why is it better? IMHO to say the least excessive body movements ... - Zowie
    • @AlexWindHope support you! - Michael Nikolaev
    • And what's bad? Do we add input'u additional id or just use his name? The taste and color markers are different © - Palmervan
    • It is yes :) <br> And again, depending on the size of the form, if there are many innput then yes, and so - excessive gestures ... - Zowie

    <div id="id"></div> note, the layer identifier must be a div according to your code, that is, like this: <div id="div"></div>

    • An abstract example, the TS has already written in comments that the problem has been solved, and the correct answer has already been chosen :) - Zowie