Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • jQuery not() Method

    • 0
    • 1
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 219
    Comment on it

    In jQuery not() method,  we set a  criteria. Elements that match the criteria are expelled from the selection, and those do not  match will be returned.

    Below is the syntax of jquery filter method:-

    selector.not( selector )

    Parameters

    selector − it is used to select html elements in which jQuery has to be applied by using either id , class or html elements.

    Below is the html code for jQuery not() method.

    <html>
    <head>
    </head>
    <body>
    <h1>Jquery not method </h1>
    <div>Lorem ipsum.</div>
    <div class="highlight"> Test Test Test Test Test Test</div>
    <div class="highlight"> Test Test Test Test Test Test</div>
    <div>Lorem ipsum.</div>
    </body>
    </html>

    Below is the jquery code which we have to put on head tag of our html document.

    <script>
    $(document).ready(function(){
        $("div").not(".highlight").css("background-color", "red");
    });
    </script>

    The above script will check all the div, those div which have class highlight get expelled and those which dont have class highlight will get highlighted with red background color.

    Working demo :- https://jsfiddle.net/1aqycm0m/1/

     

 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: