我需要使用原型在我的页面中淡出一个 div。如何在原型中淡出 jquery 代码?
$('.exercise-main .content .loading-failure').fadeOut(function(){
//my code
}
我需要使用原型在我的页面中淡出一个 div。如何在原型中淡出 jquery 代码?
$('.exercise-main .content .loading-failure').fadeOut(function(){
//my code
}
我认为您将需要使用script.aculo.us(它是出色的prototype.js 的一个很好的附加组件)以实现淡入淡出效果。
基本语法
new Effect.Fade('id_of_element', [options]);
或者
new Effect.Fade(element, [options]);
完整的代码。
<html>
<头部>
<title>script.aculo.us 例子</title>
<script type="文本/javascript"
src="/javascript/prototype.js"></script>
<script type="文本/javascript"
src="/javascript/scriptaculous.js?load=effects"></script>
<script type="text/javascript">
功能淡化效果(元素){
新效果。淡入淡出(元素,
{持续时间:1});
}
功能显示效果(元素){
新效果。出现(元素,
{持续时间:1,从:1.0,到:1.0});
}
</脚本>
</head>
<正文>
<div onclick="FadeEffect('hideshow')">
点击我淡出图像
</div>
<br />
<div onclick="ShowEffect('hideshow')">
点击我再次显示图像
</div>
<br />
<div id="hideshow">
<img src="/images/scriptaculous.gif" alt="script.aculo.us" />
</div>
</正文>
</html>
教程链接 - http://www.tutorialspoint.com/script.aculo.us/scriptaculous_fade_effect.htm
我自己使用过prototype.js和这个插件,所以如果你遇到任何问题,请随时发表评论.. :-)