All TalkersCode Topics

Follow TalkersCode On Social Media

devloprr.com - A Social Media Network for developers Join Now ➔

jQuery CSS

jQuery CSS is used to get and set CSS styles to elements to set or get the style it uses css() property.


Syntax For Setting Single Property

css("property","value");


$("a").css("color","green");

Syntax For Setting Multiple Property

css({"property1":"value1","property2":"value2", "property3":"value3",...});


$("a").css({"color":"green","font-size":"20px"});

You can also add and remove element classes by these properties addClass(), removeClass().


jQuery addClass()

$("button").click(function(){
  $("a").addClass("active");
});

jQuery removeClass()

$("button").click(function(){
  $("a").removeClass("active");
});
❮ PreviousNext ❯