I am using the following code in my form (Website/Web page) to control the font size, i.e. to either increment or decrement it.
The code works, however, when I first click on the increment button instead of increasing the font size it decreases it, but this happens ONLY on the FIRST initial click. Afterwards, it works as it should do, i.e. increases the font size.
What I am doing wrong? Any assistance will be much appreciated.
[CODE] (in the JSHeader)
var min=8;
var max=18;
function increaseFontSize() {
var p = document.getElementsByTagName(‘p’);
for(i=0; i<p.length; i++) {
if(p[i].style.fontSize) {
var s = parseInt(p[i].style.fontSize.replace(“px”,“”));
} else {
var s = 12;
}
if(s!=max) {
s += 1;
}
p[i].style.fontSize = s+“px”
}
}
function decreaseFontSize() {
var p = document.getElementsByTagName(‘p’);
for(i=0; i<p.length; i++) {
if(p[i].style.fontSize) {
var s = parseInt(p[i].style.fontSize.replace(“px”,“”));
} else {
var s = 12;
}
if(s!=min) {
s -= 1;
}
p[i].style.fontSize = s+“px”
}
}
[CODE] (on the Web page)
Thanks in advance.
Nana