+ -
当前位置:首页 → 问答吧 → 关于load()的callback的问题

关于load()的callback的问题

时间:2009-09-24

来源:互联网

初学这个,看了帮助手册,学着写了个ajax翻页效果,

代码如下:

复制代码
  1. $().ready(function(){$("#divResult").load("page.php",{ "resultType": "html"},function(){
  2. $("#page a").each(function(){
  3. $(this).attr("href","javascript:void(0)");});});});
  4. function jump(url)
  5. {
  6.      $("#divResult").load(url, { "resultType": "html" });
  7.     
  8. }


这里我的目的只实现了一个,即替换了分页导航链接中所有的A的href为 :javascript:void(0),而为每个A绑定click,却不知道怎么实现,请大家帮忙解答一下
描述:效果
图片:
'700')this.width='700';if(this.offsetHeight>'700')this.height='700';" title="Click Here To EnLarge">
具体的不知道:试试下面的代码吧

var url = 'www.sina.com.cn';
$(this).attr('href','javascript:void(0)').bind('click',{foo:url},jump);


.............................


function jump(event){
        alert(event.data.foo);
}
[ 此帖被zcrane在2009-09-24 15:55重新编辑 ]

作者: tottyandbaty   发布时间: 2009-09-24

复制代码
  1. $().ready(function(){jump("divResult","page.php")});
  2. function jump(ID,url)
  3. {
  4.      $("#"+ID).load(url, { "resultType": "html"},
  5. function(){$("#page a").bind("click",function(){jump(ID,this.rel)}).attr("href","javascript:void(0)");
  6. });
  7. }

谢谢楼上的,自己摸索出来了

作者: zcrane   发布时间: 2009-09-24

相关阅读 更多