Robin Maben
Robin Maben

Reputation: 23054

Find line height within dynamically inserted element

Within a particular div/span that I might dynamically insert into the DOM, I need to find the 1em computed height(height after rendering) within that DOM element.

Just wanted to know if anyone already knows of a good way to do this before I start out.

Upvotes: 1

Views: 246

Answers (1)

Phrogz
Phrogz

Reputation: 303224

In jQuery you want the .css() method. For example, here on Stack Overflow:

$(document.body).css('line-height'); //-> "12px"

In 'vanilla' JavaScript you want getComputedStyle [specs] for modern browsers, or currentStyle for older IE versions.

Upvotes: 1

Related Questions