JSFiddle - React, Tailwind, and code Playground

by Wosley Bago

JavaScript

$(document).ready(function (){
           var clickedOnce = undefined;
                $("#primary-menu > li.menu-item-has-children").click(function(e){
                  e.preventDefault();
                  $(this).addClass('focus');
                  var $this = $(this),
                      $oTarget = e.target;
                  if (clickedOnce !== $oTarget) {
                    setTimeout(function(){ //this setTimeout is just to delay this action after the body click event handler
                      clickedOnce = $oTarget;
                       $(this).addClass('focus');
                    }, 0);
                  }
                });
                $("body").on("click", function (e) {
                  if (e.target == clickedOnce)
                    window.location = $(e.target).attr("href");
                  
                });
         
        });