[英].load() animation with external web page?
Here is basically what I want to do: 这基本上是我想要做的:
I want to slideUp() a div with my content. 我想用内容滑动一个div。 I want to .load() an external web page (on the same server) in that div and .slideDown() that div.
我想在该div中加载()在同一服务器上的外部网页,并在该div中加载.slideDown()。
For now here is what I have: 现在这是我所拥有的:
$(document).ready(function() {
$('a').click(function(){
$('.content').slideUp('1000');
$('.content').hide().load('about.html');
$(".content").slideDown('1000');
});
});
Basically here's what I get: the div .content
hides itself, loads the about.html
page, and appears. 基本上,这就是我所得到的:div
.content
隐藏自身,加载about.html
页面,然后显示。 But no slideUps or slideDowns. 但是没有slideUps或slideDowns。
Anyone has an idea? 有人有主意吗?
Sorry if this is a noob question, this is the first real time I'm trying js/jquery. 抱歉,如果这是一个菜鸟问题,这是我正在尝试js / jquery的第一次实时。
Thanks in advance. 提前致谢。
That's because those are asynchronous actions. 那是因为这些是异步动作。 You have to continue execution in callbacks:
您必须在回调中继续执行:
$('a').click(function(){
$('.content').slideUp('1000', function() {
this.hide().load('about.html', function() {
this.slideDown('1000');
});
});
});
try: 尝试:
$('a').click(function(){
var el = $('.content'), //cache content to avoid multiple calls
slidetime = 1000;
el.slideUp(slidetime,function(){ //slide up
el.hide().load('about.html',function(){ //afterwards, load
el.slideDown(slidetime); //afterwards, slide
});
});
});
you are passing string '1000' to slideUp or slideDown. 您正在将字符串“ 1000”传递给slideUp或slideDown。 It should be number or string that it can take like 'slow'...
它应该是数字或字符串,例如“ slow”(慢)...
Try This 尝试这个
$(document).ready(function() {
$('a').click(function(){
$('.content').slideUp(1000);
$('.content').hide().load('index2.html');
$(".content").slideDown(1000);
});
});
Cheers :) 干杯:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.