 <p>You can use <a href="http://api.jquery.com/closest/" rel="nofollow"><strong>.closest()</strong></a> to find parent then check its length</p> <p><em>Code</em></p> <pre><code>$(document).on("click", ".Topping-details", function () { var ordersdiv = $(this).closest('#ordersdiv').length; var activateUiHTML = $(this).closest('div.activateUiHTML').length; if (ordersdiv) { alert('Under ordersdiv'); } if (activateUiHTML) { alert('Under activateUiHTML'); } }); </code></pre> <p><a href="http://jsfiddle.net/8nFgB/" rel="nofollow"><strong>DEMO</strong></a></p>