jQuery按类查找单击按钮的ID [英] jQuery find ID of clicked button by class
本文介绍了jQuery按类查找单击按钮的ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的页面上有许多具有相同类名称的按钮.但是,这些按钮具有不同的 ID.我该怎么做:
I have numerous buttons on my page with the same class names. However these buttons have different ID's. How do i do this:
$(".vote").click(function(){
var id = $(this).{ID OF CLICKED BUTTON};
});
我怎样才能使这个伪代码工作?
How can i make this pseudo code work?
谢谢
推荐答案
$(".vote").click(function(){
var id = this.id;
});
ID 可直接从元素访问.绝对不需要使用 jQuery 方法.
The ID is accessible directly from the element. There's absolutely no need to use a jQuery method.
这篇关于jQuery按类查找单击按钮的ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文