Last active
July 15, 2017 23:35
-
-
Save jessb321/77637b386617128168ec60a5a420adf4 to your computer and use it in GitHub Desktop.
This file contains 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 = function(){ | |
const text = $(this).html(); | |
const testElem = document.createElement('span'); | |
testElem.style.opacity = 0; | |
$(testElem).html('<span>'+text+'</span>'); | |
document.body.appendChild(testElem); | |
$(testElem).remove(); | |
return width; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment