Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • What is .not() method in jquery ?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 349
    Comment on it

    Hello Readers,

    .not() is the jquery method and it is the opposite of filter() method and this method used for return elements that do not match or do not select the certain criteria and those not matched the certain criteria they will be removed. This method also used with the grouped elements.

    Syntax :

    $(selector).not(criteria,function(index))
    

    Parameter :

    criteria : this is a optional parameter which specifies a selector expression or element to be removed from a group of selected elements.

    function(index) : this parameter is also optional which specifies a function to run for each element in a group of matched element.

    Code Example :

    <html>
    <head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
    <script>
    $(document).ready(function(){
        $("p").not(".intro").css("background-color", "yellow");
    });
    </script>
    </head>
    <body>
    
    <h1>Welcome to My Homepage</h1>
    
    <p>My name is Donald.</p>
    <p class="intro">I live in Duckburg.</p>
    <p class="intro">I love Duckburg.</p>
    <p>My best friend is Mickey.</p>
    
    </body>
    </html>
    

    In the above code we use the .not() method and use the selector p tag having class name intro so in the above code remove the element having class name intro and change the background color to yellow to the rest of element in jquery.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: