Skip to content Skip to sidebar Skip to footer

Getelementbyid Innerhtml Not Work For Me?

getElementById innerHTML not work for me ? When user fill data in input tag, it's will be change data to Hello! http://jsfiddle.net/59DFY/21/

Solution 1:

Use value property of input text.

The value property sets or returns the value of the value attribute of a text field.

The value property contains the default value OR the value a user types in (or a value set by a script).

So try to Change it like this

functionchangeMe() {
  document.getElementById("hola").value ="Hello!";
}

http://jsfiddle.net/59DFY/21/

Solution 2:

You need to use value. It will "change" the inner HTML on the input element, but that's not displayed on the screen since it's a void element. It does not technically have innerHMTL but browsers will do something like <input ...>Hello!</input>. The text for an input element uses value other than innerHTML that for example an <p> or <div> would use.

functionchangeMe() {
    document.getElementById("hola").value="Hello!"; 
}

Post a Comment for "Getelementbyid Innerhtml Not Work For Me?"