如何选择使用jQuery多个元素 [英] How to select multiple elements with jQuery
本文介绍了如何选择使用jQuery多个元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是新来的JQuery / javascript等等......基于以下文章: 如何使"< A HREF"标签是指什么?
I'm new to JQuery/Javascript etc... based on the following article: How to make the "<a href" tag refer to nothing?
我想申请的Java函数几个ID的。我们不能,而不是id的类函数执行?
I would like to apply the java function to several id's. Can we not make the function execute for classes as opposed to ids?
<span class="style1" id="myid">Link</span>
<span class="style1" id="myid">Link</span>
<span class="style1" id="myid">Link</span>
<span class="style1" id="myid">Link</span>
<span class="style1" id="myid">Link</span>
$('myid').click(function() {
/* put your code here */
});
基本上如上,我怎么执行功能上面所有的链接?这可能吗?先谢谢了。
Basically as above, how do I execute the function above for ALL of the links? Is this possible? Thanks in advance.
推荐答案
使用以下
$('.style1').click(function() {
/* put your code here */
});
这增加了一个单击处理程序与类含有 STYLE1
的所有元素。你不应该有重复的ID
This adds a click handler to all elements with class containing style1
. You should not have duplicate IDs
这篇关于如何选择使用jQuery多个元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文