Changing .css in jQuery using static values

Go To StackoverFlow.com

0

I used the PHP below using regex to resize the font-size/line-height of an html page. I'd like to create similar functionality 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);
}
2012-04-03 23:38
by jsuissa


2

You can use jQuery's .data() for that.

$("img").data("yourvar", "yourvalue");
2012-04-03 23:40
by Starx