0
我有这样的HTML标记。jQuery:提交时检查表单的父级div'sclass
<div class="formSection custom">
<form id="support">
</form>
<div>
类名“定制”到div动态添加,我需要检查表单提交。
到目前为止,我有这个,它不工作。
$('#support').on('submit', function(e) {
if ($(".support").parent().hasClass("custom")) {
alert("Yeah, It does have class");
}
}
它的工作原理,当我做
if ($(".formSection").hasClass("custom"))
我不希望我的jQuery是那么死板。我想追查表格的父母并检查其班级。有没有办法我可以做到这一点?