I am working in jquery and javascript.Here is my problem.
I have want to find a pixel length of a string.
So what is did is
var text = 'abc';
$('body').append('<span id="string_span" style="font-weight: bold; font-size: 0.7em">' + text
+ '</span>');
console.log("width of text is " + $('#string_span').width());
$('#string_span').remove();
But the problem is that what ever is my text length it is always returning 49.
Can any one guide me where i am doing wrong
Also I get correct values of width when I append my span to some other div instead of body
thanks
variable name is text, not ‘abc’. DEMO