$(function() { $(".bigger").click(function() { var thisEle = $(".list_cont_content div,.list_cont_content p").css("font-size"); var thisLine = $(".list_cont_content div,.list_cont_content p").css("line-height"); var textFontSize = parseFloat(thisEle, 10); var textLineheight = parseFloat(thisLine, 10); var unit = thisEle.slice(-2); var unline = thisLine.slice(-2) var cName = $(this).attr("class"); if (cName == "bigger") { if (textFontSize == 30) { textFontSize = 30; textLineheight = 60; } else { textFontSize += 1; textLineheight += 2; } } $(".list_cont_content div,.list_cont_content p").css("font-size", textFontSize + unit); $(".list_cont_content div,.list_cont_content p").css("line-height", textLineheight + unline); $(".list_cont_content span").css("font-size", textFontSize + unit); $(".list_cont_content span").css("line-height", textLineheight + unline); $(".list_cont_content font").css("font-size", textFontSize + unit); $(".list_cont_content font").css("line-height", textLineheight + unline); }); $(".medium").click(function() { var thisEle = $(".list_cont_content div,.list_cont_content p").css("font-size"); var thisLine = $(".list_cont_content div,.list_cont_content p").css("line-height"); var textFontSize = parseFloat(thisEle, 10); var textLineheight = parseFloat(thisLine, 10); var unit = thisEle.slice(-2); var unline = thisLine.slice(-2) var cName = $(this).attr("class"); if (cName == "medium") { textFontSize = 16; textLineheight = 32; } $(".list_cont_content div,.list_cont_content p").css("font-size", textFontSize + unit); $(".list_cont_content div,.list_cont_content p").css("line-height", textLineheight + unline); $(".list_cont_content span").css("font-size", textFontSize + unit); $(".list_cont_content span").css("line-height", textLineheight + unline); $(".list_cont_content font").css("font-size", textFontSize + unit); $(".list_cont_content font").css("line-height", textLineheight + unline); }); $(".smaller").click(function() { var thisEle = $(".list_cont_content div,.list_cont_content p").css("font-size"); var thisLine = $(".list_cont_content div,.list_cont_content p").css("line-height"); console.log(thisLine) var textFontSize = parseFloat(thisEle, 10); var textLineheight = parseFloat(thisLine, 20); console.log(textLineheight) var unit = thisEle.slice(-2); var unline = thisLine.slice(-2) var cName = $(this).attr("class"); if (cName == "smaller") { if (textFontSize < 30) { textFontSize -= 1; textLineheight -= 2; } if (textFontSize == 10) { textFontSize = 16; textLineheight = 32; return; } } $(".list_cont_content div,.list_cont_content p").css("font-size", textFontSize + unit); $(".list_cont_content div,.list_cont_content p").css("line-height", textLineheight + unline); $(".list_cont_content span").css("font-size", textFontSize + unit); $(".list_cont_content span").css("line-height", textLineheight + unline); $(".list_cont_content font").css("font-size", textFontSize + unit); $(".list_cont_content font").css("line-height", textLineheight + unline); }); });