Add HTML content and text content before using the innerHTML and InnerText methods,
There are also insertadjacenthtml and insertAdjacentText methods recently found,
These two methods are more flexible and can insert HTML content and text content in the specified place.
The insertAdjacentText method is similar to the insertAdjacentHTML method except that only plain text is inserted and the parameters are the same
Prototype: insertadajcenthtml (Swhere,stext)
insertAdjacentHTML Method: Inserts an HTML tag statement at the specified place
Parameters:
Swhere: Specifies where the HTML tag statement is inserted, with four values available:
1.beforeBegin: Insert before the label starts
2.afterBegin: After inserting the tag start tag
3.beforeEnd: Before the label end tag
4.afterEnd: After inserting the tag end tag
Stext: What to insert
<script language= "javascript"
function myfun ()
{
var obj = document.getElementById ("btn1");
obj.insertadjacenthtml ("Afterend", "<br><input name=\" txt1\ ">");
}
</script>
<body>
<input name= "txt";
<input Id= "BTN1" name= "btn1" type= "button" value= "More ..." onclick= "myfun ()";
</body>