When you want to use Javascript to change HTML, how do you know when to use either of the following?
document.getElementById("randomNumber").value = number;
document.getElementById("randomNumber").innerHTML = number;
Question&Answers:osWhen you want to use Javascript to change HTML, how do you know when to use either of the following?
document.getElementById("randomNumber").value = number;
document.getElementById("randomNumber").innerHTML = number;
Question&Answers:osSetting the value
is normally used for input/form elements. innerHTML
is normally used for div, span, td and similar elements.
Here is a link showing the use of ID.value: http://www.javascript-coder.com/javascript-form/javascript-form-value.phtml