English 中文(简体)
如何为许多纽芬兰人增加点击事件?
原标题:How to add click event for many buttons JQuery?

我有这样的ton子:

id= button0 
id= button1 
id= button2 
id= button3     
id= button4 
...

我愿为他们中的所有人增加点击。 我如何能够以多数业绩来做到这一点?

最佳回答

simple

你们应该使用阶级!

<span  class="MySpan"> ...

<span  class="MySpan"> ...

<span  class="MySpan"> ...

$(".MySpan").click (....
问题回答

开始(^=)

Something like $("button[id^= button ]")

业绩是明智的,不能确定^的影响是什么。

ref: http://api.jquery.com/attribute-starts-with-selector/

    $("*[id^= button ]").click(
        function() {
        }
     );




相关问题
C# delegate with string reference to c++ callback

I wrote a C# application that uses an unmanaged c++ dll via managed c++ dll. In the unmanaged dll, there s a callback that one of its params is std::string&. I can t seem to find the right way to ...

how to call anonymous delegate dynamically

I hava a delegate public delegate void Context(); And i had implemented it by anonymous method, public Context fakeHttpContext = () => { ... create fake ...

self.delegate = self; what s wrong in doing that?

self.delegate = self; what s wrong in doing that? and what is the correct way of doing it? Thanks, Nir. Code: (UITextField*)initWith:(id)sender:(float)X:(float)Y:(float)width:(float)hieght:(int)...

Compiler treatment of a Delegate

If i declare a delegate public delegate void firstDelegate(string str); firstDelegate handler = Strfunc; handler("Hello World"); .. static void Strfunc(string str) { Console....

Practical use of interface events [closed]

What is a good example of the power of interface events (declaring events inside interface)? Most of the times I have seen only public abstract methods inside interface.

Delegates in C#

I`m having some trouble in understanding how delegates in C# work. I have many code examples, but i still could not grasp it properly. Can someone explain it to me in "plain english"? Of course! ...

热门标签