Friday, January 1, 2010

Re: [jQuery] Re: Element Exact Width

Vidas,

I got stuck on what you did in the 'obj.html(obj.children().html());' Isn't it a redundancy or I'm missing something?



2010/1/1 Šime Vidas <sime.vidas@gmail.com>

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"));



--
At,
Leo Balter
http://leobalter.net
Blog técnico: http://blog.leobalter.net

No comments: