JSFiddle - React, Tailwind, and code Playground
HTML
<div id="computed">This div has width and height set in CSS.</div>
CSS
#computed{
width: 14em;
height: 14em;
background: rgba(00,00,00,.3);
}
JavaScript
$('#computed').click(function(){
alert($(this).css('width') + "\n" + $(this).width()
+ "\n" + $(this).emWidth());
});
(function($){
$.fn.emWidth = function(){
var wpx = this.width();
var temp = $('<div />').css({
width:'1em',
position: 'absolute'
});
this.append(temp);
var oneEm = temp.width();
temp.remove();
var value = wpx/oneEm;
return Math.round(value*100)/100;
};
})(jQuery);