How do I get the width of text in pixels using JavaScript or jQuery?
1 answer
Just wrap the text in (invisible) span
and use jQuerys.width () to get the width.
Please note, you should not, like others, use div
it as it is a block element and depending on where / how you insert it, the block element can automatically expand to its full available width and give bad results.
+3
source to share