Font Resize with Line-Height and limited Clicks


/ Published in: jQuery
Save to your folder(s)

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


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.