JavaScript Reference/Javascript Properties/innerHTML

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

"innerHTML" Example

   <source lang="javascript">
   

<html> <body>

Sample Text inside a p element

<button onclick="alert(myP.innerHTML);">InnerHTML</button> <button onclick="alert(myP.innerText);">InnerText</button> </body> </html>


     </source>
   
  


"innerHTML" is applied to

   <source lang="javascript">

+----------------+--------------------------------------------------------------+ | Applied_To |<a> <acronym> | | |<address> <applet> | | |<area> | | |<base> <basefont> | | | |

| |
<body> |

| |
<button> |

| |
|

| | | | |<col> <colgroup> | | |<custom>

| | | |

| |<dir>
| | |
| | | <fieldset> | | | <form> | | |<frame> <frameset> | | |<head> <hn> | | |
<html> |

| | <iframe> | | |<img> | | |<isindex> | | |<label> <legend> |

| |
  • <link> | | |<listing> <map> | | |<marquee> <menu> | | |<meta> <nobr> | | |<noframes> <noscript> | | |<object>
      | | |<optgroup> <option> | | |

      <param> | | |

                                                            |
      |                |                                                    |
      |                |                                                     |
      |                |<script>                        <select>                      |
      |                |                                                 |
      |                |                                              |
      |                |<style>                                                  |
      |                |                                                  |
      |                |<tbody>                                                   |
      |                |                                                       |
      |                |
        | +----------------+--------------------------------------------------------------+ </source>

        "innerHTML" Syntax and Note

        <source lang="javascript"> Note: Read and write property. Specifies the HTML between the element opening and closing tags.

        Syntax:

        document.getElementById("elementID").innerHTML = value document.all.elementID.innerHTML = value // IE only


        </source>

      |

      | |<textarea> <tfoot> |

      | |
      <thead> | | |<title>