此代码:
$("#permalink a").click(function(id){
var id = this.getAttribute('href');
$("#newPostContent").load(id, function() {
$("#removeTrigger").click(function() {
$("#removeThis").hideToggle();
$("#postSingle").hideToggle();
});
});
$("#postSingle").fadeToggle();
return false;
});
在加载功能完成其工作之前显示#postSingle。我该如何调整呢?
谢谢
(今天很多问题,谢谢大家:))。
答案 0 :(得分:2)
在回调函数中 load
后,将您想要发生的所有事情发生:
$("#permalink a").click(function(id){
var id = this.getAttribute('href');
$("#newPostContent").load(id, function() {
$("#removeTrigger").click(function() {
$("#removeThis").hideToggle();
$("#postSingle").hideToggle();
});
$("#postSingle").fadeToggle();
});
return false;
});
答案 1 :(得分:-1)
您是否尝试将其包装在文档就绪块中?像:
$(document).ready(function() {
$("#permalink a").click(function(id){
var id = this.getAttribute('href');
$("#newPostContent").load(id, function() {
$("#removeTrigger").click(function() {
$("#removeThis").hideToggle();
$("#postSingle").hideToggle();
});
});
$("#postSingle").fadeToggle();
return false;
});
});