Perform an action on click if its parent element has a specific class.
If parent element has class, do something, in jQuery
JavaScript
// jQuery
$(document).ready(function() {
$("#childElement").click(function() {
if($(this).parent().hasClass("parentClass")) {
// do something
} else {
// do something else
}
})
});
Paste this snippet into a JavaScript file that is loaded by your page, or you can put it between <script> </script> tags in the footer.
jQuery is required.