I want to know exact length in pixels of String i.e. "Hello World".
It should not be length of my container.
Any Help???
Put your text in a <span>
and use JavaScript to measure the width of your <span>
.
HTML:
<span id="text">Dummy text</span>
JavaScript:
var textWidth = document.getElementById("text").clientWidth;
jQuery:
$('#text').width();