jQuery : how to manipulate indexes?
Posted
by
Gabriel Theron
on Stack Overflow
See other posts from Stack Overflow
or by Gabriel Theron
Published on 2012-06-05T10:32:17Z
Indexed on
2012/06/05
10:40 UTC
Read the original article
Hit count: 249
JavaScript
|jQuery
Should not be such a hard question... I'm just having a hard time figuring out how to make operations on some jquery elements, particularly their indexes. Teh codez:
$( "#docSlider" ).css("background-image", "url(../../bundles/mypath/images/maquette/img" + $( "#selectable li" ).index( this ) + (".jpg)"));
I want to make the name of the picture I load depend on the index of a jQuery selectable. So I grab the index and try to add 1... but it can't work because "+" is also a concatenator.
I've tried to parseInt as well, but it was always worth 0.
How do I simply transform the index to an integer and then concatenate it with the rest of the string?
Thank you in advance!
Edit : I'm using a function that already exists, so I can hardly change the parameters (well, I guess I can't...)
© Stack Overflow or respective owner