$(function(){ $('.A').click(function(){ /*----FOR H1----*/ if($('.article h1').length > 0){ var titleText = $('.article h1'); var titleFontSize = titleText.css('fontSize'); var titleFinalNum = parseFloat(titleFontSize, 10); var titleStringEnding = titleFontSize.slice(-2); if(this.id == 'large') { titleFinalNum += 2; } else if (this.id == 'small'){ if (titleFinalNum <= 10){ titleFinalNum = 10; }else { titleFinalNum -= 2; } } titleText.animate({fontSize: titleFinalNum + titleStringEnding},200); } /*----FOR H2----*/ if($('.article h2').length > 0){ var header2Text = $('.article h2'); var header2FontSize = header2Text.css('fontSize'); var header2FinalNum = parseFloat(header2FontSize, 10); var header2StringEnding = header2FontSize.slice(-2); if(this.id == 'large') { header2FinalNum += 2; } else if (this.id == 'small'){ if (titleFinalNum <= 10){ header2FinalNum = 8; }else { header2FinalNum -= 2; } } header2Text.animate({fontSize: header2FinalNum + header2StringEnding},200); } /*----FOR H3----*/ if($('.article h3').length > 0){ var header3Text = $('.article h3'); var header3FontSize = header3Text.css('fontSize'); var header3FinalNum = parseFloat(header3FontSize, 10); var header3StringEnding = header3FontSize.slice(-2); if(this.id == 'large') { header3FinalNum += 2; } else if (this.id == 'small'){ if (titleFinalNum <= 10){ header3FinalNum = 6; }else { header3FinalNum -= 2; } } header3Text.animate({fontSize: header3FinalNum + header3StringEnding},200); } /*----FOR THE PARAGRAPH ITEMS----*/ if($('.article p').length > 0){ var bodyText = $('.article p'); var bodyFontSize = bodyText.css('fontSize'); var lineHeight = bodyText.css('line-height'); var bodyFinalNum = parseFloat(bodyFontSize, 10); var lineHeightNum = parseFloat(lineHeight, 10); var bodyStringEnding = bodyFontSize.slice(-2); var lineHeightEnding = lineHeight.slice(-2); if(this.id == 'large') { bodyFinalNum += 2; lineHeightNum += 2; }else if (this.id == 'small'){ if (titleFinalNum <= 10){ bodyFinalNum = 6; }else { bodyFinalNum -= 2; lineHeightNum -= 2; } } bodyText.animate({fontSize: bodyFinalNum + bodyStringEnding},200); bodyText.css('line-height', lineHeightNum + lineHeightEnding); } /*----FOR THE UN-ORDERED LIST ITEMS----*/ if($('.article li').length > 0){ var unorderedListText = $('.article li'); var unorderedListFontSize = unorderedListText.css('fontSize'); var unorderedListFinalNum = parseFloat(unorderedListFontSize, 10); var unorderedListEnding = unorderedListFontSize.slice(-2); if(this.id == 'large') { unorderedListFinalNum +=2; }else if (this.id == 'small'){ if (titleFinalNum <= 10){ unorderedListFinalNum = 6; }else { unorderedListFinalNum -=2; } } unorderedListText.animate({fontSize: unorderedListFinalNum + unorderedListEnding},200); } }); });