[Javascript] Changing the font of all elements on a page
Roger Roelofs
rer at datacompusa.com
Thu Nov 25 13:38:14 CST 2004
Paul.
On Nov 25, 2004, at 12:06 PM, Paul Cowan wrote:
> It's a complex problem needing me to change font-size on the browser
> and not when the page is rendered.
>
> OK let me simplify the question.
>
> How do I change the font-size in an element.
>
> I'd rather not change the element element class name
>
> i.e. element.style.class = 'differentFont';
I've been doing less javascript and more css lately, but i think I can
answer this.
You can set any style rule in javascript using the style object (but
not the className).
Generally you look up the css rule you want to emulate, and remove the
hyphen, so
font-size: 8em; becmose
element.style.fontSize = ".8em";
It would likely be easier to add another class which contains the style
changes you need. It is easy to have multiple classes on one object.
<input type="test" class="mainclass secndaryclass" />
And you can change this on the fly by changing the className attribute.
hth
Roger,
Roger Roelofs
Know what you value.
More information about the Javascript
mailing list