Lao Lao - 3 months ago 6
jQuery Question

How to check if the click was directly in an element or some of its children only?

I don't want clicks on children other than some, and the parent div itself to trigger any events.

Please see this, which does not do what I want:

$(document).ready(function() {

$('#parent').on('click', function(event) {
alert("you clicked directly on me!");



you can use

Example :

$(document).ready(function() {
  $("div").on("click", function(event) {
    alert("You click on : " +
<script src=""></script>
<div>this is Div
  <p>This is p</p>