Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
44
rated 0 times [  50] [ 6]  / answers: 1 / hits: 22990  / 13 Years ago, sun, december 11, 2011, 12:00:00

Weird little snafu. I'm using jQuery's .css() method to change the size of text (long story; no, I can't use media queries) using a variable and I need to add em to it. I'm not sure what the syntax is because there are multiple values for the CSS change.



To illustrate:



This works perfectly. It adds em to the calculated value of victore:



$('h1').css('font-size', victore + 'em');


This doesn't:



$('h1').css({
'font-size':victore + 'em',
'line-height':vignelli + 'em';
});


The em needs quotes... but so does the value. Wrapping it in parens didn't work


More From » jquery

 Answers
6

You shouldn't have the quotes around the whole thing:



$('h1').css({
'font-size': victore + em,
'color':'red'
});

[#88620] Friday, December 9, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tomas

Total Points: 165
Total Questions: 111
Total Answers: 103

Location: Maldives
Member since Tue, Dec 21, 2021
2 Years ago
;