Return to Snippet

Revision: 41775
at March 15, 2011 22:30 by pedromagalhaes


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

Revision: 41774
at February 23, 2011 06:36 by pedromagalhaes


Initial Code
$(document).ready(function(){
	$("a.zoom").click(function(){
		var $speech = $('.div');
		var currentSize = $speech.css('font-size');
		var num = parseFloat(currentSize,10);
		var unit = currentSize.slice(-2);
		if(this.id == 'plus' && num <= 16){ num *= 1.2; }
		else if(this.id == 'minus' && num >= 10) { num /= 1.2; }
		$speech.css('fontSize', num + unit);
		$speech.css('line-height', (num+6) + unit);
	 });
});

Initial URL

                                

Initial Description
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

Initial Title
Font Resize with Line-Height and limited Clicks

Initial Tags

                                

Initial Language
jQuery