Lego2012
10/28/2016 - 8:05 AM

jQuery Klassen

jQuery Klassen

// 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.
*/