javascript - How can I appendChild to a text field? -
i trying create text field takes user input , creates tag if valid email id.
i using appendchild()
method append tags after creating them unable so.
below code append <span>
field:
html
<textarea id="customfield" class="mdl-textfield__input" type="text" rows="1"></textarea>
js
document.getelementbyid("customfield").appendchild(spanparent);
i not sure right way this, great if can help.
you cannot use appendchild()
input field, instead, use container of input field, see live action here: https://jsfiddle.net/37b2fa2e/2/.
you should consider using insertbefore() method, helps inserting specified node before reference node child of current node.
Comments
Post a Comment