Jump to content

Changing fontsize with JS


ginerjm

Recommended Posts

I've tried everything I know.  Want to increase the fontsize of a group of "classed" elements depending upon the device the user has.

 

Recognizing the device is working; recognizing the elements with class="x" is working.  But I can't get my font to increase.  Funny thing is right after I modify the style, I put an alert and it even said that I had succeeded, yet the display doesn't show the change.

 

I'm using this at this point:

 

var p = getElementsByClassName("lblfont");
for(i=0;i<p.length;i++)
{
    if (w<500)
   {
       setStyle(p[i],"fontSize","font-size","58px");
    }
                }
               function setStyle(el, jsprop, cssprop, newval)
              {
   if (el.currentStyle) 		//IE
  {
	el.style[jsprop] = newval;
  }
   else
        if (el.style.setProperty)
                       {
            el.style.setProperty(jsprop,newval);
       }
       else 			//try and get inline style
       {
            el.style[cssprop] = newval;
       }
            }

[\code]

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.