我有 JavaScript 方法,它在提交特定类 (mcb) 表单时起作用:
function BindCloseMessage() {
$(".mcb").submit(function(event) {
alert("closing..."); //Here I want to get the id of form
event.preventDefault();
});
}
代替警报调用,我需要访问调用提交的表单的 ID。我该怎么做?更好的是访问任何属性的提示......
谢谢
最佳答案
正在提交的表单的 ID 将是
this.id
或者在 jQuery 中
$(this).attr('id') //although why type the extra letters?
关于javascript - 如何使用 jQuery 访问元素 ID 和其他属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1305466/