Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
#1 2008-11-11 17:46:17
- rondy
- New Member
- Registered: 2008-10-27
- Posts: 2
Index for the current iteration
There is some way to get the “index” for the current iteration inside a form? What I wanna do:
On the fifth iteration, I’d add a css class (named “last”) like this:
<div class="box">...</div>
<div class="box">...</div>
<div class="box">...</div>
<div class="box">...</div>
<div class="box last">...</div>
With the index, i would verify if the iteration is multiple of 5…
Sorry for bad english.
Offline
Re: Index for the current iteration
Would the zem_nth plug-in do what you need?
Stuart
In a Time of Universal Deceit
Telling the Truth is Revolutionary.
Offline
Re: Index for the current iteration
If zem_nth doesn’t work out for you, you could try getting it done with jQuery. Based on markup you provided you can put this into the <head>
of your page template.
<script type="text/javascript" src="<txp:site_url />textpattern/jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$(".box:nth-child(5n)").addClass("last");
});
</script>
I recently wrote a blog post about this simple technique— jQuery’s nth-child selector makes for rainbows. The post has further details, instructions, and an example.
Txp admin themes | dropshado.ws – a blog for design noobs like me
Offline
#4 2008-11-11 20:15:33
- rondy
- New Member
- Registered: 2008-10-27
- Posts: 2
Re: Index for the current iteration
Thank you guys, so much. Zem_nht is exacty what I was looking for (JQuery would be my last alternative).
Offline
Pages: 1