How do you use the [attribute=value] selector?
var prev = b - 1;
var previousImage = $('.header ul.active').find($('li[rel=prev]'));
The 1st variable is an integer being deducted by 1.
The next variable named previousImage
is what i'm having trouble with. Each one of the l开发者_如何学JAVAi
s within the previousImage
has a rel tag. Each increasing by 1. I just want to select that li
with a rel tag of the number (in this case a variable).
Can someone please explain to me exactly how to use the [rel=ATTRIBUTE] selector?
don't use another jquery object, you can do all of what you want in one easy call.
var previousImage = $('.header ul.active li[rel=' + rel + ']');
var previousImage = $('.header ul.active').find($('li[rel="' + prev + '"]'));
Note that The [attribute=value] selector requires the value Part to Be wrapped in double quotes like so:
[attribute="value"]
var previousImage = $('.header ul.active').find($('li[rel="'+prev+'"]'));
You used the string prev
instead of the variable.
Also quotes are mandatory in an equals selector.
Try to use .next()
this will help u i guess http://api.jquery.com/next/
U will just use $('li').next()
thats all
精彩评论