JSFiddle - React, Tailwind, and code Playground

by steve

HTML

<div id="outer" onclick="outerToggle()">
    outer
    <div id="inner" onclick='innerToggle()'>
        inner
    </div>
</div>


<script type='text/javascript'>
function outerToggle() {
  if($('inner').style.display=='block') { 
    $('inner').style.display = 'none'; 
   } 
  else { 
    $('inner').style.display = 'block'; 
   }
}
    
function innerToggle() {
    // Will bubble to outerToggle(); no need to handle display here.
}
</script>

CSS

#outer {
    background:red;
    height:50px;
    width:100px;
    cursor:pointer;
}

#inner {
     background:blue; 
     height:30px;
     width:30px;
     display:none;  
}

JavaScript

/*
When I wrote this, Javascript wasn't working on this site, so I put 
the functions in the HTML instead.
*/