简体   繁体   English

单击按钮后,jQuery Fadeout将不起作用

[英]Jquery Fadeout won't work upon clicking of button

I would like to show a <div> that displays "Saved!" 我想显示一个显示“已保存!”的<div> every time the user clicks the save button. 每次用户单击保存按钮。

I have here some jQuery code but it works only once. 我在这里有一些jQuery代码,但只能运行一次。 The second time I click the button the div won't show up. 第二次单击该按钮时,div将不会显示。

$("#loading").html("Saved!").fadeOut(4000);

Possibly because it is hidden. 可能是因为它是隐藏的。 Try: 尝试:

$("#loading").html("Saved!").show().fadeOut(4000);

Or 要么

$("#loading").html("Saved!").fadeIn(200).fadeOut(4000);

That is because the div is still "faded out" 那是因为div仍然“淡出”

try this... 尝试这个...

$("#loading").html("Saved!").fadeOut(4000, function(){
    $("#loading").empty();
    $("#loading").show();
});

It empties the #loading div and then re-displays it and readies it for the next click. 它清空#loading div,然后重新显示它并为下一次单击做好准备。

You need to bind a click event to aa div. 您需要将click事件绑定到div。

$(document).ready(function() {
        $('#element').click(function() {
            $('#para').html("Saved!").fadeOut(4000);
        });
    });

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

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