Splynx
Splynx

Reputation: 833

Can't get right width or outerWidth of <label> element

simply can not understand this problem I have - I need the .outerWidth() of a <label> element, but it keeps returning a value that is different from the one I can read out of my firebug?

.outerHeight works just fine though.

SOLVED: Note to self: custom fonts and calculations of width does not work all that well, lol

Upvotes: 1

Views: 2318

Answers (3)

Jonas Geiregat
Jonas Geiregat

Reputation: 5442

Maybe you need .outerWidth(true) wich includes the margin of the element.

http://api.jquery.com/outerWidth/ for more specific information on the outerWidth function.

Upvotes: 3

Pasky
Pasky

Reputation: 41

When you use custom fonts, you must use the .outerHeight method on $(window).load(function(){}, not $(document).ready(function(){}. The first case waits for all the elements of the window to be loaded (including the custom font and the image) otherwise in the second case it is ready before the custom element is loaded and it not know the dimension of it.

Upvotes: 4

Splynx
Splynx

Reputation: 833

SOLUTION/PROBLEM: I used custom fonts - must be a workaround though - dont have time to find it yet :-D

Upvotes: 0

Related Questions