JSFiddle - React, Tailwind, and code Playground

HTML

<input type="checkbox" value="1" name="1">
<input type="checkbox" value="2" name="2">
<input type="checkbox" value="6" name="3">
    
    <p id="test"></p>

JavaScript

$("input[type=checkbox]").click(function(){
    var sum=0;
    $("input[type=checkbox]:checked").each(function(index){
        sum += Number($(this).val().replace( /[^\d.]/g,''));
    });
    $("#test").html(sum);
} );