JavaScript Tutorial/DOM Node/outerText — различия между версиями

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

Текущая версия на 11:24, 26 мая 2010

Get outerText value for a tag (Firefox does not support the outerText.)

   <source lang="javascript">

<html> <head> <title>OuterText Example</title> <script type="text/javascript">

   function useOuterText() {
       var oDiv = document.getElementById("div1");
       alert(oDiv.outerText);
       oDiv.outerText = "new value";
       alert(document.getElementById("div1"));
   }

</script> </head> <body>

This is my original text

<input type="button" value="Use OuterText" onclick="useOuterText()" /> </body> </html></source>


Set outer Text (Firefox does not support the innerText property.)

   <source lang="javascript">

<html> <head> <title>OuterText Example</title> <script type="text/javascript"> function useOuterText() {

   var oDiv = document.getElementById("div1");
       oDiv.outerText = "This is some new text not inside a DIV.";
   }

</script> </head> <body>

This is my original DIV

<input type="button" value="Use OuterText" onclick="useOuterText()" /> </body> </html></source>