Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

jquery how to detect click outside off-canvas-navigation

$(document).mouseup(function(e) {
    var $offCanvasInner = $(".off-canvas-inner");

    // if the target of the click isn't the $offCanvasInner nor a descendant of the container
    if (!$offCanvasInner.is(e.target) && $offCanvasInner.has(e.target).length === 0) {
      if($('.off-canvas-wrapper').css('display') == "block"){
        $('.off-canvas-wrapper').hide();
      }
    }

});
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #jquery #detect #click
ADD COMMENT
Topic
Name
4+8 =