Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to increase/decrease element font-size on click event using jquery?

I am doing a site for the visually impaired. I have three button:

  1. increase font
  2. reduce the font
  3. in normal mode

I need by clicking add +2 pixels for font-size for the class *. Please help how it can I be implemented in javascript.

like image 390
TriSTaR Avatar asked Aug 15 '26 02:08

TriSTaR


1 Answers

JQUERY

 size=parseInt($('p').css('font-size'));


    $("#big").on("click",function(){

      size=size+2;
       $("p").css("font-size",size + "px");
    });
    $("#normal").on("click",function(){
      size=14;
       $("p").css("font-size",size + "px");
    });
    $("#small").on("click",function(){
      size=size-2;
       $("p").css("font-size",size+ "px");
    });

HTML

 <p>CLICK ME!</p>
  <button id='big'>BIG</button>
  <button id='normal'>NORMAL</button>
  <button id='small'>SMALL</button>

LINK JSBIN

like image 164
Karthikeyan Sekar Avatar answered Aug 17 '26 16:08

Karthikeyan Sekar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!