JavaScript Reference/Javascript Methods/insertAdjacentText

Материал из Web эксперт
Перейти к: навигация, поиск

"insertAdjacentText()" Example

   <source lang="javascript">
   

<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>

</body> </html>


     </source>
   
  


"insertAdjacentText()" is applied to

   <source lang="javascript">

+----------------+--------------------------------------------------------------+ | Applied_To |<a> <address> | | |<area> | | |<basefont> |

| |
<body> |

| |<button> |

| |
|

| | <comment> | | |<custom>

| | | <dir> |

| |
|

| |

| | |<fieldset> | | |<form> <frameset> |

| |<hn>
|

| | <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"> | | |<label> <legend> |

| |
  • <listing> | | |<map> <marquee> | | |<menu> <nobr> | | |
      <option> | | |

                               |
      |                |                                                     |
      |                |<select>                                               |
      |                |                                                |
      |                |                                                 |
      |                |                           <td>                          |
      |                |<textarea>                      <th>                          |
      |                |                                                       |
      |                |
        | +----------------+--------------------------------------------------------------+ </source>

        "insertAdjacentText()" Syntax, Parameters and Note

        <source lang="javascript"> 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.


        </source>