jQuery替换onclick [英] jQuery replacement for onclick
本文介绍了jQuery替换onclick的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我刚刚发现了jQuery的强大功能。只是一个简单的问题。
I've just recently discovered the power of jQuery. Just a quick question though.
onclick =DeleteSomething('服务器端加载的ID号')的替换是什么?
What is a replacement for onclick="DeleteSomething('THE ID NUMBER LOADED IN BY SERVER SIDE')" ?
有没有办法以某种方式将自定义信息(如ID)传递给jquery onclick?或者我必须保持老式的方式?
Is there even a way somehow to pass custom information such as an ID to a jquery onclick? Or do i have to stay with the old fashioned way?
非常感谢!
Adam
推荐答案
我通常使用rel =来获取可能需要附加到按钮或其他什么的额外数据。
I usually use a rel="" for some extra data i might need attached to the button or whatnot.
例如
<input class="btnDelete" rel="34" value="Delete" />
然后在jquery
$('.btnDelete').click(function() {
DeleteMethod($(this).attr("rel"));
});
这篇关于jQuery替换onclick的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文