I have input form like this:
<form>
<label for="name">Name :</label>
<input type="text" id="name">
</form>
I want to add span tag with Javascript using this code:
var inputName = document.getElementById('name');
var h = document.createElement("span");
var t = document.createTextNode("Hello World");
h.appendChild(t);
inputName.appendChild(h);
But it seem it doesn't work as i expected. this is the result that i get:
<form>
<label for="name">Name :</label>
<input type="text" id="name">
<span>Hellow World</span>
<input>
</form>
So how do i can do that properly? and if you would be kind to tell me how can i remove that span later. thanks.
errorElement.textContent = errorMessage.