get element by id returns null for elements that were dynamically added
using javascript
function createInput(id){
count++;
var name = "name" + count;
var text = "#" + id.id;
var newInput = "<input type='text' id='" + name + "' placeholder='' />";
var myTextArea = document.getElementById(id.id);
myTextArea.innerHTML += newInput;
return false;
}
The above function adds an input type to a textarea in a div in my code.
Once the input type is displayed dynamically, i try to get it's element id
using getElementById but it returns null. May I know what is going wrong
here? It seems that the new input type is added but somehow the input type
is null.
No comments:
Post a Comment