Found this, which I reckon might be a slightly bigger load ?

$(""#stepsList li").each(function(i) {
       $(this).click(function() {
// REFERENCE "i" IN HERE TO GET THE ITEM NUMBER
       }
}

Pity ".click" doesn't take the same index parameter :(

Any ideas, or for those in the know is the above much of a load difference ?

TIA
L

Liam Byrne wrote:

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>
------------------------------------------------------------------------


No virus found in this incoming message.
Checked by AVG - www.avg.com Version: 8.0.237 / Virus Database: 270.11.8/1984 - Release Date: 03/04/09 19:17:00


Reply via email to