A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://webplatform.github.io/docs/dom/HTMLElement/sourceIndex below:

sourceIndex ยท WebPlatform Docs

sourceIndex

Property of dom/HTMLElementdom/HTMLElement

Syntax
var result = element.sourceIndex;
element.sourceIndex = value;
Examples

This example uses the sourceIndex property to identify the previous and next elements in the all collection (deprecated).

<SCRIPT>
function fnHandler(){
   
   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>

View live example

Syntax Attributions

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4