jquery fadeIn不工作

前端之家收集整理的这篇文章主要介绍了jquery fadeIn不工作前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
有人可以告诉我我做错了:

样式:

@H_403_4@.warning{border: 1px solid #F0AAAA; background:#FFBABA; color: #C90000;}

标记

@H_403_4@<p class="warning">A successful authorization already exists. Further authorizations are not allowed at this time.</p>

脚本:

@H_403_4@$().ready(function () { alert($(".warning").html()); // WORKS $(".warning").fadeIn(4000); // DOESN'T WORK });

解决方法

除非元素被隐藏,否则不会发生淡入淡出,你需要这样的东西: @H_403_4@$(".warning").hide().fadeIn(4000);

You can give it a try here,$()在1.4中被弃用,你应该使用$(document)或更短的版本,像这样:

@H_403_4@$(function() { $(".warning").hide().fadeIn(4000); });

另一种方法是给元素一个显示:none,但是这会打破JS禁用的用户,或者如果JavaScript错误防止褪色,所以你可能想要避开这种方法

猜你在找的jQuery相关文章