如何选择使用jQuery多个元素多个、如何选择、元素、jQuery

由网友(在伤口上洒了盐)分享简介:我是新来的JQuery / javascript等等......基于以下文章:如何使"< A HREF"标签是指什么? I'm new to JQuery/Javascript etc... based on the following article: How to make the...

我是新来的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

阅读全文

相关推荐

最新文章