JSFiddle - React, Tailwind, and code Playground

by galivan

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<div class="wrap">
  <div id="activatemenu">
    <div>
      <div>
        <div class="stuff">
           <p>Here is some text</p>
        </div>
       
      </div>
    </div>
  </div>
  <div class="otherstuff">
    <p>Other stuff!</p>
  </div>
</div>

CSS

.stuff{
  width:300px;
  height:150px;
  border:red 2px solid;
}
.otherstuff{
  width:400px;
  height:400px;
  background:purple;
}

JavaScript

$(function() {

	$(document).click(function(event) {

    if($(event.target).closest('#activatemenu')) {
   				 
                $('.wrap').prepend('<p>the clicked element has a parent with the id of activatemenu</p>');
               }else{
              	   $('.wrap p').remove();
               }
  
  });


});