469,344 Members | 5,413 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,344 developers. It's quick & easy.

Jquery: Not Has Class

I've got a jquery selector I'm trying to get done and since I'm somewhat new to jquery I'm stumped. Essentially. I'm trying to get a div within divs with the class "card" that do not have the class of "correct" and then select the first one out of the list.

Expand|Select|Wrap|Line Numbers
  1. $("div .card:not(.correct):nth-child("1") .question ").css('display', 'none');
After spending quite a while trying to get this to work I am now opening it up to anyone to give me a hand.
Feb 1 '09 #1
3 12311
acoder
16,027 Expert Mod 8TB
Get rid of the quotes in nth-child or use first-child.
Feb 1 '09 #2
I'm afraid thats not the problem. The quotes are there because I forgot to get rid of them. When I implemented the code the quotes were there so I could put a variable in like this:
Expand|Select|Wrap|Line Numbers
  1. "+variable+"
So the actual code is this:
Expand|Select|Wrap|Line Numbers
  1. $("div .card:nth-child("+currentCard+")").addClass("correct").removeClass("incorrect");
The currentCard variable is equal to 1.
Feb 1 '09 #3
acoder
16,027 Expert Mod 8TB
If I've understood correctly, you want a div within divs, so you'd be looking for something like:
Expand|Select|Wrap|Line Numbers
  1. $("div.card div:not(.correct):nth-child(1)")
If that's not quite what you're after, post the HTML code too.
Feb 1 '09 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by mikeh3275 | last post: by
83 posts views Thread by liketofindoutwhy | last post: by
3 posts views Thread by NetWave | last post: by
26 posts views Thread by RobG | last post: by
2 posts views Thread by souporpower | last post: by
53 posts views Thread by souporpower | last post: by
5 posts views Thread by jrod11 | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.