JSFiddle - React, Tailwind, and code Playground

HTML

<span id="master">Click to toggle</span>

<div id="slave">Toggle this content</div>

CSS

#slave {display: none}

JavaScript

$('#master').click(function() {
    $('#slave').toggle();
});

$('body').on('click', '*:not( #master, #slave )', function() {
    $('#slave').hide();
});