I am constructing an extremely simple image rotator for use in Wordpress. It is comprised of a containing DIV and the "slides" (DIVs containing the images) that I want to rotate.
The problem I have is that there are multiple instances on the page. To get round this I have used the $gallery->id
output to give me each gallery a specific container with an ID and slides which have a class specific to the gallery.
These are variables that I pass to the image rotator function.
My problem is this when I am dealing with the slides that I select thus $('.'+myvar)
, I have no problem - the animation works as expected. But, when I go to select the containing DIV and I use the selector $('#'+myvar2)
I get no response. I have checked in Firebug and the ID of the div is what I expect it to be, console is not flagging any errors.
If I do
var divindex = $('#'+myvar2).index();
alert(divindex);
I get the answer -1
. this, I read in the jQuery doc means that no object exists with that ID.
I do not understand as I am using the same notation as for the class selector, only substituting '#
' for the '.
'.
(a) What am I doing wrong? - I'm working using no conflict notation, this is simplified (b) What can I do as a work round?