Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Font Size Changer

  • This topic is empty.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #32948
    Waffle
    Member

    How can I make this code increase & Decrease multiple tags font sizes.. Basically. I want it to change the font size of EVERYTHING on the page, not just

    Help?

    var min=8;
    var max=18;
    function increaseFontSize() {
    var p = document.getElementsByTagName('p');
    for(i=0;i if(p.style.fontSize) {
    var s = parseInt(p
    .style.fontSize.replace("px",""));
    } else {
    var s = 12;
    }
    if(s!=max) {
    s += 1;
    }
    p
    .style.fontSize = s+"px"
    }
    }
    function decreaseFontSize() {
    var p = document.getElementsByTagName('p');
    for(i=0;i if(p
    .style.fontSize) {
    var s = parseInt(p
    .style.fontSize.replace("px",""));
    } else {
    var s = 12;
    }
    if(s!=min) {
    s -= 1;
    }
    p
    .style.fontSize = s+"px"
    }
    }

    #74682
    Waffle
    Member

    I imagine its something to do with the variables, but I’ve tried things and not working so good.

    #74638
    Johnnyb
    Member

    Hey Waffle, you ever thought about using jQuery? I don’t really code in raw javascript but you could accomplish this quite easily using jQuery.

    #74555
    Waffle
    Member

    Oh right? I’ll give it a gander

Viewing 4 posts - 1 through 4 (of 4 total)
  • The forum ‘CSS’ is closed to new topics and replies.