如何发送多个参数到jQuery点击功能? [英] How to send multiple arguments to jQuery click function?
本文介绍了如何发送多个参数到jQuery点击功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
目前我使用的是:
$('.myclass').click(function(){
var msg = $(this).attr('id');
alert(msg)
});
和HTML:
< a href="#" class="myclass" id="101">Link</a>
如果我需要其他参数,我该如何阅读?也是目前的方式,我使用正确的方式?最初我使用隐藏的输入字段,所以它已经是一个步骤。 :p
If I need additional parameters how would I read them? Also is the current way I am using the proper way? Originally I was using hidden input fields so it was already a step up. :p
推荐答案
$('.myclass').bind("click", { Param1: "", Param2: 2 }, function(event){
alert(event.data.Param2);
});
这篇关于如何发送多个参数到jQuery点击功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文