Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • jQuery CSS Classes

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 410
    Comment on it

    JQuery helps us to easily handle the CSS of the elements. jQuery provides several methods to handle CSS elements. These methods are :-

    addClass() :- This allows to add one or more than one classes to the selected elements

    $("button").click(function(){
        $("h1, h2, p").addClass("blue");
        $("div").addClass("important");
    });

    removeClass() :-  This removes one or more than one classes from the selected elements

    $("button").click(function(){
        $("h1, h2, p").removeClass("blue");
    })

    toggleClass() :- It toggles between adding and removing classes from the selected elements

    $("button").click(function(){
        $("h1, h2, p").toggleClass("blue");
    });

    css() :- The css() method sets or returns one or more style sttributes for the selected elements.

    • Set a CSS Property :-  Use the following syntax  to set a specified CSS property.
    css("propertyname","value");

    Example :- 

    $("p").css("background-color", "yellow");

    It will set the background-color value for ALL matched elements:

    • Return a CSS Property :-  Use the following syntax to return the value of a specified CSS property.
    css("propertyname");

    Example :- 

    $("p").css("background-color");

    It will return the background-color value of the FIRST matched element.

 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: