简体   繁体   中英

How to add a node to the end of the textarea

i have an array of control ids and this is how i retrieve them

var control = document.getElementById(arrVarIDToControlID[variable_id]);

for the text boxes am able to append the node to the parent node(textbox) but for the text area am not able to append the node to the parent(textarea) but it adds the node to the page instead

 control.parentNode.appendChild("text");

i use the above code to append. how can i be able to append to the textarea but not the page??

尝试在TextArea控件上使用insertAfter()

$(arrVarIDToControlID[variable_id]).insertAfter("text");

Have you tried:

$('#'+arrVarIDToControlID[variable_id]).parent().append('<div>text</div>');

You can try to append the text only but I recommend to always use a container

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM