[英]How to launch the normal function in jquery
I have some links to launch ajax. 我有一些启动Ajax的链接。
<a href="javascript:void(0)" onclick="artClick(1)">1</a><br>
<a href="javascript:void(0)" onclick="artClick(2)">2</a><br>
<a href="javascript:void(0)" onclick="artClick(3)">3</a><br>
.
.
These links are made by script so I cant use #id. 这些链接是由脚本创建的,因此我不能使用#id。
my javascript is this 我的JavaScript是这个
function artClick(id){
$.post(url,
{
id:id
},function(data){
});
}
but it doesnt work. 但它不起作用。 I think I should use
我想我应该用
$(document).ready(function() {
});
But if I put the function in this,nothing changes. 但是,如果我在其中放置函数,则没有任何改变。
I want to know the good way to handle the multiple links and ajax. 我想知道处理多个链接和Ajax的好方法。
1 : include jQuery library in 1:在其中包含jQuery库
2 : add ready(); 2:添加ready(); function
功能
3 : inside ready function add such 3:在内部准备功能中添加这样的
$("a").click(function(){
atext = $(this).text();
$.post(url,{id:atext},function(data){
// here what do you want
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.