JSFiddle - React, Tailwind, and code Playground

by Kiran Duggal

HTML

<div id="foo">
    <p>foo bar baljlkjljljljkz taz laz</p>
</div>

JavaScript

$.fn.textWidth = function(){
        var self = $(this),
            children = self.children(),
            calculator = $('<span style="display: inline-block;">'),
            width;

        children.wrap(calculator);
        width = children.parent().width();
        return width;
    };

$(function(){
    var foo = $("#foo");
    console.log(foo);
    console.log(foo.html());
    console.log(foo.textWidth());
});