JSFiddle - React, Tailwind, and code Playground

HTML

<div id="divToTest">
    This is an example text to test the functionality.
</div>

CSS

#divToTest
{
    border: 1px solid black;
    width: 100px; 
    /*
    change width to test different scenarios
    100 = multiline
    500 = singleline */
}

JavaScript

$(function() {
    var $original = $('#divToTest');
    var $target = $('<text/>').css('visibility', 'hidden').text($original.text());
    
    $('body').append($target);
    
    var styles = ["width", "margin-left", "margin-right", "margin-top", "margin-bottom", "padding-left", "padding-right", "padding-top", "padding-bottom", "word-wrap"];
    for (var i = 0; i < styles.length; i++) {
        $target.css(styles[i], $original.css(styles[i]));
    }
    
    $target.css('display', 'block');
    
    $target.css('white-space', 'nowrap');
    var nowrapHeight = $target.height();
    
    $target.css('white-space', 'normal');
    var normalwrapHeight = $target.height();
    
    //debugger;
    if(nowrapHeight != normalwrapHeight) {
        alert("Text is multiline!");
    } else {
        alert("Text is singleline!");
    }
    
});