JSFiddle - React, Tailwind, and code Playground

by Somnath Kharat

HTML

<button>Size of all divs?</button><br>
<div style="width: 100px;">REMOVE</div>
<div style="width: 150px;">REMOVE</div>
<div style="width: 200px;">REMOVE</div>
<div style="width: 150px;">REMOVE</div>
<div style="width: 100px;">REMOVE</div>

CSS

div {
    width: 100px;
    height: 100px;
    background: gray;
    color: #FFF;
    line-height: 100px;
    text-align: center;
    font-size: 20px;
    border-radius: 10px;
    margin: 20px;
    cursor:pointer;
    float:left;
    overflow:hidden;
}

JavaScript

var divs;
$('button').click(function () {
    divs=0;
    $('div').each(function () {
        divs += $(this).outerWidth(true);
    });
    alert(divs + 'px');
});

$('div').click(function () {
    $(this).remove();
});