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
https://forums.phpfreaks.com/topic/246809-changing-fontsize-with-js/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.