Give the li's an ID and just use that for the step number

e.g:

<li id="step-1">Step one</li>
<li id="step-2">Step two</li>


Then:
<script>
$("#stepsList li").click(function() {
  // load stepContent  ===> not a problem
  
   id = $(this).attr('id');
   $("#stepFooter").html("Viewing "+ id.replace("-"," ") +" of  
"+$("#stepsList li").length);

})
</script>

Un tested but you get the idea...



-----Original Message-----
From: [email protected] [mailto:[email protected]] On
Behalf Of Liam Byrne
Sent: 05 March 2009 12:25
To: [email protected]
Subject: [jQuery] Current item child index ?


Hi folks

Just wondering if there's a quick/shorthand way of doing this:

I'm doing a navigation system where I want clickable items but I want to

put the "current item number" in a footer, e.g.

Any ideas of a quick way (without using each) to get "CURRENTSTEPNUMBER"

? Basically the reverse of nth-child ?

CODE OUTLINE (IF IT HELPS) :

<script>
$("#stepsList li").click(function() {
  // load stepContent  ===> not a problem

   $("#stepFooter").html("Viewing step "+CURRENTSTEPNUMBER+" of  
"+$("#stepsList li").length);

})
</script>


<h1>STEPS TO BE COMPLETED</h1>
<ul id="stepsList">
<li>step one</li>
<li>step two</li>
</li>step three<li>
</ul>

<div id="stepContent">

<div id="stepFooter">
</div>
</div>

***********************************************************************************************************
 
IMPORTANT INFORMATION & CONFIDENTIALITY NOTICE 
The information in this e-mail is confidential and may be legally privileged. 
It is intended solely for the named recipient.  Access to this Email by anyone 
else is unauthorised. 
 If you are not the intended recipient or the employee or agent responsible for 
delivering the message to the recipient named, 
please note that any use, disclosure, copying, distribution of this e-mail or 
any action taken or omitted to be taken in reliance on it is 
prohibited.  If you are not the intended recipient, please inform us by 
returning a copy of the e-mail with the subject 
line marked "wrong address" and then deleting the e-mail, and any attachments 
and any copies of it.  Any questions should be directed 
to  [email protected]. 

Sheffield International Venues Limited uses regularly updated anti-virus 
software in an attempt to reduce the possibility 
of infection. However we do not guarantee that any attachments to this e-mail 
are virus free. 

***********************************************************************************************************
 

Reply via email to