【发布时间】:2009-07-17 22:27:48
【问题描述】:
对于不共享一个类的两个不同元素,我有两个相同的点击事件,例如:
$("#element_1").click(function(){
alert("hello world");
});
$("#element_2").click(function(){
alert("hello world");
});
我正在寻找一种方法来将相同的点击功能分配给它们两个,而无需外部化该功能或重复它(如上所示)。 如果元素共享同一个类,我会做这样的事情:
$(".element_class").click(function(){
alert("hello world");
});
但他们没有。如何在 jQuery 1.3 中实现类似的功能?
谢谢!
【问题讨论】:
标签: javascript jquery jquery-1.3