sourceIndex property
Retrieves the ordinal position of the object, in source order, as the object appears in the document's all collection.
Syntax
| JavaScript | |
|---|
Property values
Type: Integer
the ordinal position.
Examples
This example uses the sourceIndex property to identify the previous and next elements in the all collection.
Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/sourceIndex.htm
<script type="text/javascript"> function fnHandler(){ // Retrieve the element that fired the event. var oElement=event.srcElement; var iIndex=oElement.sourceIndex; var sTagName=oElement.tagName; if(sTagName=="!"){ sTagName="comment"; } oVal1.innerText=iIndex; oVal2.innerText=sTagName; if(iIndex-1>0){ sTagName=document.all[iIndex-1].tagName; if(sTagName=="!"){ sTagName="comment"; } oVal3.innerText=sTagName; } else{ oVal3.innerText="Cannot read."; } if(iIndex+1<document.all.length){ sTagName=document.all[iIndex+1].tagName; if(sTagName=="!"){ sTagName="comment"; } oVal4.innerText=sTagName; } else{ oVal4.innerText="Cannot read."; } } </script> <body onmousemove="fnHandler()"> <table> <tr> <td>Source Index:</td> <td id="oVal1"></td> </tr> <tr> <td>Object Name:</td> <td id="oVal2"></td> </tr> <tr> <td>Previous Object:</td> <td id="oVal3"></td> </tr> <tr> <td>Next Object:</td> <td id="oVal4"></td> </tr> </table> </body>
See also
- a
- abbr
- acronym
- address
- applet
- area
- article
- aside
- b
- bdo
- big
- blockQuote
- body
- br
- button
- caption
- center
- cite
- code
- col
- colGroup
- custom
- dd
- del
- dfn
- dir
- div
- dl
- dt
- em
- embed
- fieldSet
- figcaption
- figure
- font
- footer
- form
- frame
- frameSet
- head
- header
- hgroup
- hn
- hr
- html
- i
- iframe
- img
- input type=button
- input type=checkbox
- input type=email
- input type=file
- input type=hidden
- input type=image
- input type=number
- input type=password
- input type=radio
- input type=range
- input type=reset
- input type=search
- input type=submit
- input type=tel
- input type=text
- input type=url
- ins
- isIndex
- kbd
- label
- legend
- li
- listing
- map
- mark
- marquee
- menu
- nav
- nextID
- noBR
- object
- ol
- optGroup
- option
- p
- plainText
- pre
- q
- rt
- ruby
- s
- samp
- section
- select
- small
- span
- strike
- strong
- sub
- sup
- table
- tBody
- td
- textArea
- tFoot
- th
- tHead
- tr
- tt
- u
- ul
- var
- xmp
Show: