Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Highlighting important information with the help of jquery

    • 0
    • 1
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 246
    Comment on it

    Many time we want to show some information in our page to be highlighted, we want some important information to be display with different background color. we can acquire this by simply using jquery filter() method.

    In jquery filter method  we set a  criteria. Elements that don't match the criteria are expelled from the selection, and those that match will be returned.

    Below is the syntax of jquery filter method:-

    selector.filter(selector )

    Parameters

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

    Below is the html code for jquery filter() method .

    <html>
    <head>
    </head>
    <body>
    
    <h1>Jquery filter 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").filter(".highlight").css("background-color", "red");
    });
    </script>

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

     

 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: