www.webdeveloper.com
Results 1 to 5 of 5

Thread: [RESOLVED] jQuery :not isn't working

Hybrid View

  1. #1
    Join Date
    Nov 2013
    Posts
    41

    resolved [RESOLVED] jQuery :not isn't working

    I have this, but it doesn't work:
    Code:
    $("div#parent:not(p#child)").fadeIn(5000);
    I don't want to fadeIn the child paragraph, but I do want to fadeIn all of the other children. The code above just applies fadeIn to everything. I tried using .not() too, but that didn't change anything.

  2. #2
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,648
    Code:
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8" />
    <title>123</title>
    <style>
    body{text-align:center;}
    #child_1,#child_2,#child_3{display:none;margin-top:100px;}
    </style>
    <script src="http://code.jquery.com/jquery-latest.min.js"></script>
    <script>
    $(document).ready(function(){
    $('#parent').children().not('#child_2').fadeIn('slow');
    });
    </script>
    </head>
    <body>
    <div id="parent">
    <div id="child_1">#child_1 --------> fadeIn</div>
    <div id="child_2">#child_2 --------> not fadeIn</div>
    <div id="child_3">#child_3 --------> fadeIn</div>
    </div>
    </body>
    </html>
    xxx: Guess Buddhist riddle: "What is the sound of one hand clapping?"
    yyy: facepalm

  3. #3
    Join Date
    Nov 2013
    Posts
    41
    First of all, it didn't work. I can't see why. The other problem is that I have $.ajax append to the div after the fadeOut it is supposed to fadeIn after that. I'm just going to add another parent.

  4. #4
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,648
    1. first of all, it works in Opera, IE, Firefox and Safari.
    2. nobody knows what you have in your code if you didn't show it
    xxx: Guess Buddhist riddle: "What is the sound of one hand clapping?"
    yyy: facepalm

  5. #5
    Join Date
    Nov 2013
    Posts
    41
    Sorry, but I figured it out:
    HTML Code:
    <div id="parent">
        <p id="child"></p>
        <div id="otherchildren"> <!-- NEW -->
            <!-- Other Children -->
        </div>
    </div>
    Instead of using :not or .not() I put all of the other children in a new container, and addressed that instead.
    Code:
    $("div#parent div#otherchildren").fadeIn(5000);
    Sorry, I marked this resolved.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles