JSFiddle - React, Tailwind, and code Playground

by joshdavenport

HTML

<p>Click either of the paragraphs to remove one and re-check amount</p>
<p class="info">This would not have a border because there are two</p>
<p class="info">This would not have a border because there are two</p>

CSS

.info.highlight { border: 1px solid black }

JavaScript

var $info;

$(document).ready(function () {
    
    function highlightSingularInfo () {
        $info = $('.info');
        console.log($info.length);
        if ($info.length === 1) { $info.addClass('highlight'); }
    }
    highlightSingularInfo();
    
    $info.on("click",function(){
        $(this).remove();
        highlightSingularInfo();
    });
});