.value
gives the current value of the form element ( input
, select
, textarea
), while .innerHTML
builds an HTML string based on the DOM nodes contained in this element.
For a simple example, go to the JS Fiddle demo and enter a new value in input
, and then go from input.
The test uses the following JavaScript:
document.getElementById('input').onchange = function(){ alert('innerHTML: ' + document.getElementById('input').innerHTML + '; whereas value: ' + document.getElementById('input').value); };
(The above text has been updated, after a comment left by me , in the comments below.)
source share