April 3, 2012
Changing .css in jQuery using static values
Question by jsuissa
I used the PHP below using regex to resize the font-size/line-height of an html page.
I’d like to create similar fucntionality in jQuery.
Is there a way to store static values for an entire method like .css() so each time the scale calculations are based off the original value instead of their current value?
jQuery code excerpt:
$("#resume_holder").contents().find('body').children().css('font-size', '+=' + ui.value);
PHP Code:
private function _font_size($output,$scale,$line_height_scale = FALSE) {
$callback = new Font_Callback($scale);
$pattern = '%(bfont-size:s*)([0-9]+)%s';
$output = preg_replace_callback($pattern, array($callback, '_alter_font_size'), $output);
if ($line_height_scale === FALSE) {
$callback = new Font_Callback($scale);
} else { $callback = new Font_Callback($line_height_scale); }
$pattern = '%(bline-height:s*)([0-9]+)%s';
$output = preg_replace_callback($pattern, array($callback, '_alter_font_size'), $output);
return($output);
}