Sourav
Sourav

Reputation: 17530

Render page on user selecting a font from a list - jQuery

i want to write a code where a list will be shown to the user, the user can select any font from the list, on choosing a font, the content of the page will be rendered with that font face ! dont know how to do that :(

Upvotes: 1

Views: 215

Answers (2)

Jishnu A P
Jishnu A P

Reputation: 14390

$("#changeFont").change(function(){
$("*").css("font-family",this.value);
});

Change font is a dropdown like this

<select id='changeFont'>
   <option value='Arial'>Arial</option>
    ......
</select>

Upvotes: 1

Shad
Shad

Reputation: 15461

I recommend writting your CSS like this:

body.arial {font-family:arial;}
body.tahoma {font-family:tahoma;}

and then just use JavaScript to change the body's class when the user selects the font.

$(document.body)[0].className=SelectedFont;

Upvotes: 1

Related Questions