jQuery 到 Prototype 转换:鼠标悬停时动态 SlideUp div
我使用这个 jQuery 代码动态地在其包装 div 上滑动一个 div:
jQuery.fn.masque = function(classSelector) {
$(this).hover(function(){
$(this).find(classSelector).stop().animate({height:'88px',opacity: '0.8'},400);
},function () {
$(this).find(classSelector).stop().animate({height:'0',opacity: '0'}, 300);
});
};
$(document).ready(function(){$('.thumb').masque('.masque');});
HTML 是这样的:
<div class="thumb">
<a href="something.html"><img src="something.jpg" /></a>
<div class="masque">
<h3>Something</h3>
<p> Something e</p>
</div>
</div>
“masque”div (CSS : height: 0;display:none;position:absolute;)在“thumb”内部向上滑动包装 div(CSS:位置:相对;)。
我在同一页面中有很多“拇指”div,这就是为什么我需要动态完成它,因此只有特定“拇指”内的“面具”div向上滑动(当鼠标未结束时向下滑动) 。
对于这个特定项目,我已经从 jQuery 迁移到 Prototype/Scriptaculous(不要问为什么 :-D ),我需要将此代码转换为 Prototype/Scriptaculous..
有人可以帮我吗?
注意:它不需要与 jQuery 代码完全相同,我只需要相同的行为风格。
I use this jQuery code to slide up a div over its wraper div dynamically:
jQuery.fn.masque = function(classSelector) {
$(this).hover(function(){
$(this).find(classSelector).stop().animate({height:'88px',opacity: '0.8'},400);
},function () {
$(this).find(classSelector).stop().animate({height:'0',opacity: '0'}, 300);
});
};
$(document).ready(function(){$('.thumb').masque('.masque');});
The HTML is like this:
<div class="thumb">
<a href="something.html"><img src="something.jpg" /></a>
<div class="masque">
<h3>Something</h3>
<p> Something e</p>
</div>
</div>
The "masque" div (CSS : height: 0; display: none; position: absolute;) slides up inside the "thumb" wraper div (CSS: position: relative;).
I have a lot of "thumb" divs in the same page, thats why I need it to be done dynamically so only the "masque" div inside that specific "thumb" is slided up (and slided down when the mouse is not over).
I have moved from jQuery to Prototype/Scriptaculous for this specific project (don't ask why :-D ) and I need to convert this code to Prototype/Scriptaculous..
Can someone please help me out?
Note: It doesn't need to be exactly equal to the jQuery code I just need the same behaviour style.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
主要问题是 scriptaculous 没有 stop():你必须将效果保存在某个地方。
也许
我仍然不确定它是否真的正确或优雅!
The main problem is that scriptaculous doesn't have stop(): you have to hold the effect somewhere.
Maybe it would be
I'm still not sure if it's actually correct or elegant!