samedi 5 mai 2012

How to use jQuery css method

jQuery provides .css() method to get and set the various CSS properties for the element. This method can be used to set one or multiple CSS properties for any element. You can also get the CSS property value using this method. In this post, I will show you all the 3 operations.



Set single CSS Property

//Code Starts
$("p").css("background-color", "LightGrey");
//Code Ends
Set multiple CSS Properties

//Code Starts
$("span").css({"background-color": "Green","color":"Yellow"});
//Code Ends
Get value of CSS Property

//Code Starts
$("div").html($('span' ).css("font-size"));
//Code Ends
See result below.







Feel free to contact me for any help related to jQuery, I will gladly help you.

Aucun commentaire:

Enregistrer un commentaire