Jan 5, 2011
Switch font size using jQuery
HTML part:
<ul id="resizer">
<li id="f_text"> font size: </ li>
<li id="f_s"> <a href="javascript:void(0)"> small </ a> </ li>
<li id="f_m"> <a href="javascript:void(0)"> in </ a> </ li>
<li id="f_l"> <a href="javascript:void(0)"> big </ a> </ li>
</ ul>
Then do not forget to introduce jQuery library, this is not to say, just a reminder, the last is the simple lines of the code:
$ (document). ready (function () {
$ ('# resizer li'). click (function () {
var fontSize = 1.4;
var name = $ (this). attr ('id');
if (name == 'f_s') {
fontSize -= 0.1
} Else if (name == 'f_l') {
fontSize + = 0.1
} Else if (name == 'f_m') {
fontSize == 1.4
}
$ ('. entry p'). css ('font-size', fontSize + 'em') / / '. entry p' is to the body of the selector control
});
});
Maintained by BPOVIA Web Design Team





Recent Comments