JavaScript Reference/Javascript Properties/innerHTML — различия между версиями

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

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

"innerHTML" Example

    
<html>
<body>
<p id="myP">Sample Text inside a <b>p</b> element</p>
<button onclick="alert(myP.innerHTML);">InnerHTML</button>
<button onclick="alert(myP.innerText);">InnerText</button>
</body>
</html>



"innerHTML" is applied to

+----------------+--------------------------------------------------------------+
| Applied_To     |<a>                             <acronym>                     |
|                |<address>                       <applet>                      |
|                |<area>                          <b>                           |
|                |<base>                          <basefont>                    |
|                |<bdo>                           <big>                         |
|                |<blockquote>                    <body>                        |
|                |<br>                            <button>                      |
|                |<caption>                       <center>                      |
|                |<cite>                          <code>                        |
|                |<col>                           <colgroup>                    |
|                |<custom>                        <dd>                          |
|                |<del>                           <dfn>                         |
|                |<dir>                           <div>                         |
|                |<dl>                            <dt>                          |
|                |<em>                            <fieldset>                    |
|                |<font>                          <form>                        |
|                |<frame>                         <frameset>                    |
|                |<head>                          <hn>                          |
|                |<hr>                            <html>                        |
|                |<i>                             <iframe>                      |
|                |<img>                           <ins>                         |
|                |<isindex>                       <kbd>                         |
|                |<label>                         <legend>                      |
|                |<li>                            <link>                        |
|                |<listing>                       <map>                         |
|                |<marquee>                       <menu>                        |
|                |<meta>                          <nobr>                        |
|                |<noframes>                      <noscript>                    |
|                |<object>                        <ol>                          |
|                |<optgroup>                      <option>                      |
|                |<p>                             <param>                       |
|                |<pre>                           <q>                           |
|                |<rt>                            <ruby>                        |
|                |<s>                             <samp>                        |
|                |<script>                        <select>                      |
|                |<small>                         <span>                        |
|                |<strike>                        <strong>                      |
|                |<style>                         <sub>                         |
|                |<sup>                           <table>                       |
|                |<tbody>                         <td>                          |
|                |<textarea>                      <tfoot>                       |
|                |<th>                            <thead>                       |
|                |<title>                         <tr>                          |
|                |<tt>                            <u>                           |
|                |<ul>                            <var>                         |
+----------------+--------------------------------------------------------------+



"innerHTML" Syntax and Note

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