admin管理员组文章数量:1287230
I have JavaScript method which acts when a particular class (mcb) of forms are submitted:
function BindCloseMessage() {
$(".mcb").submit(function(event) {
alert("closing..."); //Here I want to get the id of form
event.preventDefault();
});
}
In place of alert call, I need to access the id of form whose submit is called. How can I do it? Even better will be the tip for accessing any attribute...
Thanks
I have JavaScript method which acts when a particular class (mcb) of forms are submitted:
function BindCloseMessage() {
$(".mcb").submit(function(event) {
alert("closing..."); //Here I want to get the id of form
event.preventDefault();
});
}
In place of alert call, I need to access the id of form whose submit is called. How can I do it? Even better will be the tip for accessing any attribute...
Thanks
Share Improve this question edited Aug 20, 2009 at 11:20 Hemant asked Aug 20, 2009 at 11:14 HemantHemant 19.8k24 gold badges94 silver badges130 bronze badges2 Answers
Reset to default 7the id of the form being submitted will be
this.id
or in jQuery
$(this).attr('id') //although why type the extra letters?
$(".mcb").submit(function(e){
e.preventDefault();
$(this).attr("id"); // Returns FORM ID
});
You can learn more about jQuery's attribute-methods at http://docs.jquery./Attributes
本文标签: javascriptHow to access element id and other attributes using jQueryStack Overflow
版权声明:本文标题:javascript - How to access element id and other attributes using jQuery? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741307401a2371452.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论