JS snippet for increasing or decreasing font size in a HTML document using jQuery.
In your HTML, create two elements for increasing and decreasing font size, e.g.:
<button id="smaller">Smaller text</button>
and <button id="larger">Larger text</button>
Then use jQuery to call the function.
$('#smaller').click(function() {
resize('decrease', 'p', 'li', '.myclass', '#someId');
});
$('#larger').click(function() {
resize('increase', 'p');
});
All arguments should be strings.
- First argument is the direction (
'increase'
or'decrease'
), - The following (at least one) arguments are the elements which should change size. They should be elements jQuery can find.
- To change font size globally, call
resize( ... , 'body');
.
Requires jQuery.