Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

jquery check if clicked inside div

$(function() {
  $("body").click(function(e) {
    if (e.target.id == "myDiv" || $(e.target).parents("#myDiv").length) {
      alert("Inside div");
    } else {
      alert("Outside div");
    }
  });
})
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #jquery #check #clicked #div
ADD COMMENT
Topic
Name
9+2 =