JavaScript Reference/Javascript Methods/insertAdjacentText
"insertAdjacentText()" Example
<html>
<body>
<script language="JavaScript">
function function1() {
var myText = "Some Sample Text";
document.all.myDiv.insertAdjacentText("afterBegin", myText);
}
</script>
<button onclick="function1();">Insert element</button>
<div id="myDiv" style="width:300; height:200;"></div>
</body>
</html>
"insertAdjacentText()" is applied to
+----------------+--------------------------------------------------------------+
| Applied_To |<a> <address> |
| |<area> <b> |
| |<basefont> <big> |
| |<blockquote> <body> |
| |<button> <caption> |
| |<center> <cite> |
| |<code> <comment> |
| |<custom> <dd> |
| |<dfn> <dir> |
| |<div> <dl> |
| |<dt> <em> |
| |<fieldset> <font> |
| |<form> <frameset> |
| |<hn> <hr> |
| |<i> <iframe> |
| |<img> <input type="button"> |
| |<input type="checkbox"> <input type="file"> |
| |<input type="hidden"> <input type="image"> |
| |<input type="password"> <input type="radio"> |
| |<input type="reset"> <input type="submit"> |
| |<input type="text"> <kbd> |
| |<label> <legend> |
| |<li> <listing> |
| |<map> <marquee> |
| |<menu> <nobr> |
| |<ol> <option> |
| |<p> <pre> |
| |<s> <samp> |
| |<select> <small> |
| |<span> <strike> |
| |<strong> <sub> |
| |<sup> <td> |
| |<textarea> <th> |
| |<tt> <u> |
| |<ul> <var> |
+----------------+--------------------------------------------------------------+
"insertAdjacentText()" Syntax, Parameters and Note
Note:
Inserts text into the specified position.
Syntax:
document.all.elementID.insertAdjacentText(param1, param2)
Parameters:
param1 Required;
beforeBegin just before the beginning of the element
afterBegin just after the beginning of the element
beforeEnd just before the end of the element
afterEnd just after the end of the element
param2 Required; the text to be inserted.