Friday, January 1, 2010

[jQuery] Re: Element Exact Width

Better yet, make a function that you can reuse:

function contentWidth(obj) {
var width = obj.wrapInner("<span></span>").children().width();
obj.html(obj.children().html());
return width;
}

Now you can use the function like this...

var width = contentWidth($("#myp"));

No comments: