我做了一个jquery函数,假设做了3个步骤
以下代码一直工作到2个步骤但是没有触发第三步,它应该再次替换所有网址我认为它应该替换加载页面的链接?
$(document).ready(function(){
var base_url = "http://localhost/dolphin/";
$("a").each(function(e){
if(this.href == "javascript:void(0)" ||
this.href == base_url ||
this.href == base_url + "index.php" ||
this.href == "javascript:void(0);" ||
this.href == "javascript:%20void(0)") {
}else{
page = 'Javascript:LoadPage(\''+ this.href + '\')';
this.setAttribute('onclick',page);
this.setAttribute('href', '#');
}
});
});
function LoadPage(url){
$("#contentarea").load(url, function() {
//after loading it should call redoIt() but it doesnt.
redoIt();
});
}
function redoIt(){
var base_url = "http://localhost/dolphin/";
$("a").each(function(e){
if(this.href == "javascript:void(0)" ||
this.href == base_url + "index.php" ||
this.href == "javascript:void(0);" ||
this.href == "javascript:%20void(0)") {
}else{
page = 'Javascript:LoadPage(\''+ this.href + '\')';
this.setAttribute('onclick',page);
this.setAttribute('href', '#');
}
});
}
答案 0 :(得分:1)
你对$.load
的调用是在一个函数内部,而且从我收集的内容中你并没有在任何地方调用它,因此它没有被执行。拿出来它应该可以正常工作
$("#contentarea").load(url, function() {
//after loading it should call redoIt() but it doesnt.
redoIt();
});