gpt4 book ai didi

jquery - 如何让错误消息淡出?在 RubyOnRails 3 中

转载 作者:行者123 更新时间:2023-12-03 22:50:36 24 4
gpt4 key购买 nike

我想显示的错误

flash[:error] = "Invalid username/password combination."

我已经尝试过

$(document).ready( function() {// When the Dom is ready
$('.error').hide();//Hide the div
$('.alert').hide();
$('.notice').hide();
$('.success').hide();
$('.info').hide();

$(".error").fadeOut(2000); //Add a fade out effect that will last for 2000 millisecond
$(".alert").fadeOut(2000);
$(".notice").fadeOut(2000);
$(".success").fadeOut(2000);
$(".info").fadeOut(2000);

});

没有成功..我已经包含了 javascript 文件

<%= javascript_include_tag 'jquery-1.3.2' %>

最佳答案

您没有办法获取错误消息。

flash[:error] = "Invalid username/password combination."

仅输出原始文本。

 flash[:error] = "<div class='error'>Invalid username/password
combination.</div>"

将其包装在容器中。

然后你可以使用 jQuery 淡出容器。

$(".error").fadeOut(2000); 

关于jquery - 如何让错误消息淡出?在 RubyOnRails 3 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6695423/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com