I\'m trying to calculate text width using jQuery. I\'m not sure what, but I am definitely doing something wrong.
So, here is the code:
var c = $(\'.c
I found this solution works well and it inherits the origin font before sizing:
$.fn.textWidth = function(text){
var org = $(this)
var html = $('' + (text || org.html()) + '');
if (!text) {
html.css("font-family", org.css("font-family"));
html.css("font-size", org.css("font-size"));
}
$('body').append(html);
var width = html.width();
html.remove();
return width;
}