Posted By

pedromagalhaes on 02/23/11


Tagged

fontsize


Versions (?)

Font Resize with Line-Height and limited Clicks


 / Published in: jQuery
 

Let's you select the classes and apply the resize and line-height.

In the example: a.zoom is the link who will trigger the function, and .div is text target

  1. $(document).ready(function(){
  2. $("a.zoom").click(function(){
  3. var $speech = $('.div');
  4. var currentSize = $speech.css('font-size');
  5. var num = parseFloat(currentSize,11);
  6. var unit = currentSize.slice(-2);
  7. if(this.id == 'plus' && num <= 16){ num += 1; }
  8. else if(this.id == 'minus' && num >= 10) { num -= 1; }
  9. $speech.css('font-size', num + unit);
  10. $speech.css('line-height', (num+6) + unit);
  11. return false;
  12. });
  13. });

Report this snippet  

You need to login to post a comment.