jQuery的找到类点击按钮的ID [英] jQuery find ID of clicked button by class
本文介绍了jQuery的找到类点击按钮的ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有我使用相同的类名称页面上众多的按钮。然而,这些按键有不同的ID。我如何做到这一点:
$(投票)。点击(函数(){
VAR ID = $(本){点击的按钮ID}。
});
我怎样才能让这个伪code的工作?
感谢
解决方案
$(投票)。点击(函数(){
VAR ID = this.id;
});
ID是直接从元件访问。绝对没有必要使用jQuery的方法。
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?
Thanks
解决方案
$(".vote").click(function(){
var id = this.id;
});
The ID is accessible directly from the element. There's absolutely no need to use a jQuery method.
这篇关于jQuery的找到类点击按钮的ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文