1

I'm trying to change css font with javascript,

I changed font-size like below and it worked

$(".bp-item.bp-title.buyuk-baslik-yazi").css("font-size",
        +jsonVerisi.ayar[0].baslikFontSize + "px");

but when I try to change font-family by the same way,it doesn't work,is there anything that i'm missing ?

$(".bp-item.bp-title.buyuk-baslik-yazi").css("font-family",
            +jsonVerisi.ayar[0].baslikFontFamily);
3
  • 1
    What is the value of jsonVerisi.ayar[0].baslikFontFamily? I'd check that first. Commented Apr 29, 2014 at 14:13
  • + is to convert a string to number.. if the string is not a valid number then it makes it NaN. Commented Apr 29, 2014 at 14:17
  • i've already checked,it is selected by user and its value comes as expected like sans,sans-serif etc. Commented Apr 29, 2014 at 14:18

2 Answers 2

3

Just remove "+" symbol from jsonVerisi.ayar[0].baslikFontFamily and try.

$(".bp-item.bp-title.buyuk-baslik-yazi").css("font-family",
            jsonVerisi.ayar[0].baslikFontFamily);

Example

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

0

Make sure that your browser support specified font because it should work in that way.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.