JavaScript Reference/Javascript Properties/outerHTML

Материал из Web эксперт
Версия от 18:30, 25 мая 2010; (обсуждение)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

"outerHTML" Example

    
<html>
<body>
<button type="button" 
        style="border-width:thin; color:red; cursor:hand;" 
        onClick="function1();">
        Button. Repeat
</button>
<div id="myD"></div>
<script language="JavaScript">
    function function1(){
        var m = event.srcElement;
        if(m.tagName != "p"){
            alert("Repeating the following HTML element:\n" + m.outerHTML);
            myD.innerHTML += m.outerHTML + "<br>";
        }
    } 
</script>
</body>
</html>



"outerHTML" is applied to

+----------------+--------------------------------------------------------------+
| Applied_To     |<a>                             <acronym>                     |
|                |<address>                       <applet>                      |
|                |<area>                          <b>                           |
|                |<bdo>                           <bgsound>                     |
|                |<big>                           <blockquote>                  |
|                |<br>                            <button>                      |
|                |<caption>                       <center>                      |
|                |<cite>                          <code>                        |
|                |<col>                           <colgroup>                    |
|                |<custom>                        <dd>                          |
|                |<del>                           <dfn>                         |
|                |<dir>                           <div>                         |
|                |<dl>                            <dt>                          |
|                |<em>                            <embed>                       |
|                |<fieldset>                      <font>                        |
|                |<form>                          <frameset>                    |
|                |<hn>                            <hr>                          |
|                |<html>                          <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">           |
|                |<ins>                           <kbd>                         |
|                |<label>                         <legend>                      |
|                |<li>                            <listing>                     |
|                |<map>                           <marquee>                     |
|                |<menu>                          <nobr>                        |
|                |<object>                        <ol>                          |
|                |<p>                             <plaintext>                   |
|                |<pre>                           <q>                           |
|                |<rt>                            <ruby>                        |
|                |<s>                             <samp>                        |
|                |<select>                        <small>                       |
|                |<span>                          <strike>                      |
|                |<strong>                        <sub>                         |
|                |<sup>                           <table>                       |
|                |<tbody>                         <td>                          |
|                |<textarea>                      <tfoot>                       |
|                |<th>                            <thead>                       |
|                |<tr>                            <tt>                          |
|                |<u>                             <ul>                          |
|                |<var>                           <wbr>                         |
|                |<xmp>                                                         |
+----------------+--------------------------------------------------------------+



"outerHTML" Syntax and Note

Note:
Read and write property. 
Sets all of the HTML content.
    
Syntax:
    
document.all.elementID.outerHTML = value