JavaScript Reference/Javascript Properties/offsetTop

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

"offsetTop" Example

   <source lang="javascript">
   

<html> <body>

<button onclick="alert(myDiv.offsetTop);">offsetTop</button> </body> </html>


     </source>
   
  


"offsetTop" is applied to

   <source lang="javascript">

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

| |
<body> |

| |
<button> |

| |
|

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

| | | |

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

| |<html> | | |<iframe> <img> | | |<input type="button"> <input type="checkbox"> | | |<input type="file"> <input type="image"> | | |<input type="password"> <input type="radio"> | | |<input type="reset"> <input type="submit"> | | |<input type="text"> | | |<isindex> | | |<label> <legend> |

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

      <param> | | |<plaintext>

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

        "offsetTop" Syntax and Note

        <source lang="javascript"> Note: Read-only properties. Return the vertical coordinates of the upper-left corner of any block-level or inline element.

        Syntax:

        document.getElementById("elementID").offsetLeft document.all.elementID.offsetLeft // IE only document.getElementById("elementID").offsetTop document.all.elementID.offsetTop // IE only


        </source>

      <textarea> |

      | |textRange <tfoot> |

      | |
      <thead> | | |<title>