English 中文(简体)
j Query: using fadeIn() with .html()
原标题:jQuery: using fadeIn() with .html()

我有一部《酒吧法》,通过《联合国邮政管理处》查询一页,然后该页回来了一些在网页上展示的文本。 这是我为成功做到的守则:

$.post(
    "query.php?module=vote",  
    {answer: ans, pid: pid, to: to, page: page},
    function(responseText){  
        $("#poll").html(responseText);  
    },  
    "html"  
);

I ve Trial changing $("#poll”).html(responseText) to $("#poll”).html(responseText.fadeIn(1500);,但未奏效。

我必须做些什么/做些什么才能使案文落到一页?

最佳回答

In order to fade in, the element must first be faded out. Try fading out instantly (0 seconds) then using a callback function to add the content and fade in.

$.post(
    "query.php?module=vote",  
    {answer: ans, pid: pid, to: to, page: page},
    function(responseText){  
        $("#poll").fadeOut(0,function(){
             $(this).html(responseText).fadeIn();
        }); 
    },  
    "html"  
);
问题回答

在你能够做些事情之前,你必须确保它隐藏起来。 为此:

$("#poll").html(responseText).hide().fadeIn(1500);

或者,你可以确保该元素被利用特别安全局隐藏:

#poll {
    display: none;
}

Live demo (showing both ways): http://jsfiddle.net/n5rnw/1/

由于弹lement显示器具,因此首先需要fadeOut/hide。 页: 1

$( #element ).fadeOut(500).html(content).fadeIn(500);




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签