Jquery: Not Has Class

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mberkom
    New Member
    • Feb 2009
    • 2

    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.

    Code:
    $("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.
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Get rid of the quotes in nth-child or use first-child.

    Comment

    • mberkom
      New Member
      • Feb 2009
      • 2

      #3
      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:
      Code:
      "+variable+"
      So the actual code is this:
      Code:
      $("div .card:nth-child("+currentCard+")").addClass("correct").removeClass("incorrect");
      The currentCard variable is equal to 1.

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        If I've understood correctly, you want a div within divs, so you'd be looking for something like:
        Code:
        $("div.card div:not(.correct):nth-child(1)")
        If that's not quite what you're after, post the HTML code too.

        Comment

        Working...