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);
}

1 Answer 1

2

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

$("img").data("yourvar", "yourvalue");
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.