jQuery Tutorial


jQuery Example


jQuery References


jQuery with CSS




How can we do jQuery with CSS?

jQuery CSS Method is perform following this three css() method are different syntax and perform different tasks.

  • css(name) - set CSS property value.
  • css(name,value) - Set CSS property and value both.
  • css({properties}) - Set one or more CSS properties and values.

jQuery css(name) Method

css(name) method use to fetch or return to the properties value.

Syntax

$(selector).css(name);

css(name) Method Example:

<script type="text/javascript"> 
$(document).ready(function(){
  $("div").click(function(){
    $("p").html($(this).css("background-color"));
  });
});
</script>
Online Try This Code Your Self....   »

jQuery css(name,value) Method

css(name,value) method use to set the proper properties values.

Syntax

$(selector).css(name,value);

css(name) Method Example:

<script type="text/javascript"> 
$(document).ready(function(){
  $("button").click(function(){
    $("p").css("background-color","aqua");
  });
});
</script>
Online Try This Code Your Self....   »

jQuery css({properties}) Method

css({properties}) method use to set one or more properties values.

Syntax

$(selector).css({properties});

css({properties}) Method Example:

<script type="text/javascript"> 
$(document).ready(function(){
  $("button").click(function(){
    $("p").css({"background-color":"aqua","font-size":"20px",
	"font-face":"Arial"});
  });
});
</script>
Online Try This Code Your Self....   »

Full Reference of jQuery with CSS Method Learn all jQuery with CSS Method References.