Loading Please Wait...
With jQuery, it is easy to manipulate the style of elements.
jQuery has several methods for CSS manipulation. We will look at the following methods:
The jQuery addClass() method adds one or more classes to the selected elements.
$("button").click(function(){
// add single class "text-red"
$("h1, h2, p").addClass("text-red");
// add multiple classes "bg-red text-white"
$("div").addClass("bg-red text-white");
});
The jQuery removeClass() method removes one or more classes from the selected elements.
$("button").click(function(){
// remove single class "text-red"
$("h1, h2, p").removeClass("text-red");
// remove multiple classes "bg-red text-white"
$("div").removeClass("bg-red text-white");
});
The jQuery toggleClass() method toggles between adding/removing classes from the selected elements.
$("button").click(function(){
// toggle single class "text-red"
$("h1, h2, p").toggleClass("text-red");
// toggle multiple classes "bg-red text-white"
$("div").toggleClass("bg-red text-white");
});
The jQuery css() method sets or returns one or more style properties for the selected elements.
$("p").css("background-color");
$("p").css("background-color", "yellow");
$("p").css({
"background-color": "yellow",
"color": "#ffffff",
"font-size": "200%"
});
How you feel about this blog:
Share this blog on:
If you find any error in the turtorials, or want to share your suggestion/feedback, feel free to send us email at: info@lynxsia.com
Contact UsWe are concern with various development process like website design & development, E-commerce development, Software development, Application development, SMS & Bulk SMS Provider, PWA Development, and many more..
Copyright ©
, Lynxsia IT Solutions, All rights reserved