I’ve managed to simulate a slideshow nested inside tabs – where the next button on the last slide in a tab can take you through to the next tab.
I’ve done it using nth-child selectors – however ive had to literally punch in a function for each nth child – eg:
if (nth-child(1)) {};
else if (nth-child(2)) {};
else is (nth-child(3)){;
etc etc
is there a way to use a range of values for the nth-child selector – something like:
if (nth-child(1-3){};
or
if (nth-child(1,2,3){};
something like that.
full code is here http:here
thanks!
Ok!
Use the
index()method: http://jsfiddle.net/fPvJK/8/$(this).index()is0-indexaccording the the place in itsparent‘schildNode-tree.If we say we have the number 3 element in the dom: (
0-index = 2)The selector is then:
and again if we take the 7th element in the dom:
0-index = 6;this would give us
Or we could just just
Math.ceilinstead ofMath.floor + 1🙂Math.floor rounds down, Math.ceil rounds up, and Math.round round to nearest:
note: using
roundwith.5round up.