By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,730 Members | 1,620 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,730 IT Pros & Developers. It's quick & easy.

Jquery: Not Has Class

P: 2
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
Share this Question
Share on Google+
3 Replies


acoder
Expert Mod 15k+
P: 16,027
Get rid of the quotes in nth-child or use first-child.
Feb 1 '09 #2

P: 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
Expert Mod 15k+
P: 16,027
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.