Change Font Family on select Drop Down – Simple jQuery script!



Here is another great tutorial – How to change font family dynamically using jQuery!!

I have used a drop down list of font-families. OnChange of the drop down box will change the font type of the document.

Go to the bottom of the page to see the DEMO or DOWNLOAD the Source Code.

Here is the jQuery part, very simple isn’t it?

$(document).ready(function() {
  $("#fontsense").change(function () {
    var str = "";
    $("#fontsense option:selected").each(function () {
	str += $(this).text() + " ";
    $("p").css('font-family', str);

Here is the Entire Code (copy paste the below example and try yourself):

 <!doctype html>
	<title>Simple jQuery Change Font Family from drop down</title>
	<script src=""></script>
        <!-- i have used some google fonts too -->
	<link href='|Aldrich|Nothing+You+Could+Do|Crete+Round|Karla:400,700|Original+Surfer|Salsa|Marmelad|Averia+Sans+Libre:700|Righteous|Sancreek|Alegreya+SC:900' rel='stylesheet' type='text/css'>
	 $(document).ready(function() {
		$("#fontsense").change(function () {
			var str = "";
			$("#fontsense option:selected").each(function () {
				str += $(this).text() + " ";
			$("p").css('font-family', str);
		#sample{margin: 0 auto; width: 900px; border: 1px solid gray; padding: 10px;}
	<div id="sample">
		Change Font: <select id="fontsense" >
			<option>Select Font</option>
			<!--default fonts-->
			<option>Comic Sans MS</option>
			<option>Trebuchet MS</option>

			<!--google fonts-->
			<option>Averia Sans Libre</option>
			<option>Alegreya SC </option>
			<option>Merienda One</option>
			<option>Nothing You Could Do</option>
		<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>


One thought on “Change Font Family on select Drop Down – Simple jQuery script!

Leave a Reply

Theme: Overlay by Kaira