简体   繁体   English

jQuery fadeIn()无法正常工作

[英]jQuery fadeIn() not working properly

jquery: jQuery的:

    $.post("process_login.php",
        {username : $("#username").val(), password : $("#password").val()},
        function(data) {
            $("#login_results").fadeIn("slow").html(data);
            }
        )

html: 的HTML:

<table>
    <tr><td id="login_results"></td></tr>
    <tr><td><input type="text" id="username" /></td></tr>
    <tr><td><input type="password" id="password" /></td></tr>
    <tr><td><input type="submit" id="login_submit" /></td></tr>
</table>

The data shows, but it doesn't fade in. I have no idea why. 数据显示了,但是并没有消失。我不知道为什么。 =/. = /。 If you need any other details, let me know. 如果您需要其他详细信息,请告诉我。

probably because you have them in reverse order. 可能是因为您的顺序相反。 you want 你要

$("#login_results").html(data).fadeIn("slow");

otherwise you're fading in something that doesn't have any content yet. 否则,您将淡入一种尚无任何内容的东西。

also, try putting what type of content is being returned by the post request. 另外,请尝试放置发布请求返回的内容类型。

$.post("page", {params}, function(data){}, "html");

after looking at the other answers, the more complete answer is to also make login_results invisible first: 在查看了其他答案之后,更完整的答案是也首先使login_results不可见:

<td id='login_results' style='display:none'></td>

Tables get really finicky when it comes to jquery effects. 当涉及到jQuery效果时,表变得非常挑剔。 Inserting the content into a div should do the trick: 将内容插入div应该可以解决问题:

<table>
    <tr><td><div id="login_results" style="display:none"></div></td></tr>
    <tr><td><input type="text" id="username" /></td></tr>
    <tr><td><input type="password" id="password" /></td></tr>
    <tr><td><input type="submit" id="login_submit" /></td></tr>
</table>

first, make sure that your #login_results are not visible by applying a display: none on them (either in CSS page or inline, your choice). 首先,通过应用display: none来确保#login_results不可见display: none在它们上面display: none (在CSS页面或内联中,您可以选择)。 then try this: 然后试试这个:

$.post("process_login.php",
            {username : $("#username").val(), password : $("#password").val()},
            function(data) {
                    $("#login_results").html(data);
                    $("#login_results").fadeIn('slow');
                    }
            )

sometimes chaining doesn't work the way you'd think with certain combination of processes and effects... 有时,在某些过程和效果的组合下,链接无法按照您的想法工作...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM