Created
November 17, 2015 15:01
-
-
Save sinslav/835fe4b20354da4be2b3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.fn.textWidth = (text, font) -> | |
if (!$.fn.textWidth.fakeEl) | |
$.fn.textWidth.fakeEl = $('<span>').css("white-space", "pre").hide().appendTo(document.body) | |
$.fn.textWidth.fakeEl.text(text or this.val() or this.text()).css('font', font or this.css('font')) | |
return $.fn.textWidth.fakeEl.width() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment