Mia Malkova
Mia Malkova

Reputation: 21

JavaScript/JQuery function to get the ORIGINAL height/width of an HTML element

When I use JQuery to try and get the height/width in pixels of an element, it gives me a decimal. For instance, calling $("#someDiv").height() returns something like 599.91239131923 if I have #someDiv {height: 600px;}. I'm wondering if there's some function where I could actually return the number 600, corresponding to the number I set the height to be on page load. I need that number as a constant that I use elsewhere in my web app.

Upvotes: 2

Views: 191

Answers (1)

Luke Turnbull
Luke Turnbull

Reputation: 208

Have you tried using:

$(element).css("height")

Upvotes: 2

Related Questions