hammerbrostime hammerbrostime - 4 years ago 89
Javascript Question

Is it possible to get the width of the window in em units using javascript?

I'm looking for a reliable way to get the width of the window in em units using javascript. I was surprised to see that jQuery will only return a result in pixel measurements. Any help is appreciated.

Answer Source

This seems to work:

$(window).width() / parseFloat($("body").css("font-size"));
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download