JSFiddle - React, Tailwind, and code Playground

HTML

<html>
    <body>
        <div>
            <input type="checkbox"  id="first"/><br/>
            <div>text</div>
        </div>
        <br/>
        <div>box [checked] <span id="1attr">-</span></div>
        <div>box :checked <span id="1sel">-</span></div>
        <div>siblings [checked] <span id="2attr">-</span></div>
        <div>siblings :checked <span id="2sel">-</span></div>
    </body>      
</html>

CSS

div {width:150px;}
span {float:right;}

JavaScript

function update(){
    var box = $('input[type=checkbox]');
    var siblings = box.siblings().andSelf();
    
    var box_attr = box.filter('[checked]').length;
    $('#1attr').text(box_attr);
    
    var box_sel = box.filter(':checked').length;
    $('#1sel').text(box_sel);
    
    var siblings_attr = siblings.filter('[checked]').length;
    $('#2attr').text(siblings_attr);
    
    var siblings_sel = siblings.filter(':checked').length;
    $('#2sel').text(siblings_sel);
}

$('input[type=checkbox]').click(update);       
                         
update();