On Jul 18, 2008, at 12:27 PM, benjam wrote:


I have looked and looked, and I get the same error everytime I try to
use the .css( ) function with { }:
missing : after property id

Here is my code:
$(this).css({ font-weight: 'bold', font-size: 'larger' });

Maybe a fresh pair of eyes will help?


Hi benjam,

If you're going to use the object literal syntax with hyphenated keys, you need to put the properties in quotes, too.

$(this).css({ 'font-weight': 'bold', 'font-size': 'larger' });

As an alternative, you could camelCase the properties:

$(this).css({ fontWeight: 'bold', fontSize: 'larger' });


--Karl

____________
Karl Swedberg
www.englishrules.com
www.learningjquery.com


Reply via email to