Reputation: 2168
I am setting the style of an div
, with jQuery, to a font loaded from Google Fonts, but the div
won't be displayed with that font.
Here is where I load the font, in the HTML code:
<link href='https://fonts.googleapis.com/css?family=Slabo+27px' rel='stylesheet' type='text/css'>
In my JavaScript code, I change this style of the div
like this:
$("#id").css({"font-family": "Slabo 27px, serif", "font-size": "35"});
Have a look in this example.
I would appreciate help with how to fix this - thanks :).
Upvotes: 1
Views: 756
Reputation: 76
CSS property "font-family" needs to wrapped in single quotes because it contains a space.
$("#header2").css({"font-family": "'Slabo 27px, serif'");
Upvotes: 0
Reputation: 6337
This line is what is causing your error:
$("#header2").css({"font-family": "Slabo 27px, serif", "font-size": "35"});
Change it to:
$("#header2").css({"font-family": "'Slabo 27px', serif", "font-size": "35"});
Font names with two or more words should be quoted.
Upvotes: 3