在jQuery中获取发件人 [英] Getting sender in jQuery
本文介绍了在jQuery中获取发件人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个大的复选框列表,所有复选框都带有唯一的 id
值。我想得到执行我的JavaScript函数的复选框的 id
。我可以使用 $(this)
吗?
I have a large list of check boxes all with unique id
values. I'd like to get the id
of the checkbox that executes my JavaScript function. Can I do this using $(this)
?
推荐答案
你可以使用 event.target
<获取活动目标/ a>。
You can get the target of the event using event.target
.
$('input:checkbox[id]').change(function(event) {
var checkboxID = $(event.target).attr('id');
alert(checkboxID);
});
这篇关于在jQuery中获取发件人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文