Apply advanced CSS properties on one line

Is there any possible way to apply more CSS to the control in a single line of code. In the example below, I can only apply one property

$('#<%=lblMessage.ClientID%>').css("color", "#16428b");

Suppose if I wanted to apply a font or background .. how is this possible

-Thanks

+5
source share
5 answers
.css({
    color: "#16428b",
    backgroundColor: "#f0f",
    "font-size" : "3em"
})

note the different styles for defining CSS rules: camelCase for javascript, "css-style" for quoted strings.

It is also much more efficient than multiple chains of consecutive calls .css(), since your jQuery object does not require multiple passes.

+16
source

You just bind them:

$('#<%=lblMessage.ClientID%>')
   .css("color", "#16428b")
   .css("font-family", "Helvetica, Arial, sans-serif")
   .css("background", "#ccc");

jQuery jQuery, .

Edit:
, , , :

var e = document.getElementById('<%=lblMessage.ClientID%>');
e.style.color = '#16428b';
e.style.fontFamily = 'Helvetica, Arial, sans-serif';
e.style.backgroundColor = '#ccc';
+4

.

$('#<%=lblMessage.ClientID%>').css("color", "#16428b").css("background","black");

JQuery JQuery, .

, css :

$('#<%=lblMessage.ClientID%>').css({color: "#16428b", background: "black"});

http://docs.jquery.com/CSS

+1
$('#<%=lblMessage.ClientID%>').css("color", "#16428b").css("background", "1px solid red");

?

0

Jquery css . :

$('#<%=lblMessage.ClientID%>').css({ 
   "color": "#16428b", 
   fontWeight: "bold", 
   "float": "left", 
   "font-size": 2em 
});

, , , . , .

0