[ACCEPTED]-How to add multiple CSS elements to a div using jQuery?-css

Accepted answer
Score: 49

You're thinking correctly. Using the css(map) method 4 is the way to go.

$(".cIconSmall").css({
    float: "left", 
    width: "59px", 
    background: "transparent url('http://download.com/47.jpg') no-repeat scroll -132px -1px" 
});

http://api.jquery.com/css/

A map of property-value 3 pairs to set.


Might be nicer as a css class, though... then 2 you can just write $(".cIconSmall").addClass("icon47"); but there's a time for 1 everything...

Score: 2
$(".yourClass").css({
    float: "left",
    width: "59px",
    background: "transparent url('http://download.com/47.jpg') no-repeat scroll -132px -1px"
});

0

More Related questions