jquery - 使用事件处理程序
首先...先谢谢您!
我有 4 个 div。
当每个 div 滚动时,我希望具有唯一文本的 div 出现在类名为“.rollOversHolder”的另一个 div 中
文本 div 都包含 id“#copy”,但都具有唯一的类名称,例如。 '.copy1'、'.copy2' 等
我希望 '#copy' div 单独显示在 '.rollOversHolder' div 中,当另一个按钮滚动时,我希望当前动画停止并播放新动画开始。
HTML ---
<div class="rollOversHolder">
<div id="main1" class="rollOver_1"></div>
<div id="main1" class="rollOver_2"></div>
<div id="main1" class="rollOver_3"></div>
<div id="main1" class="rollOver_4"></div>
</div>
<div class="emptyCopyClass"></div>
<div id="copy" class="copy1">
Test text _01
</div>
<div id="copy" class="copy2">
Test text _02
</div>
<div id="copy" class="copy3">
Test text _03
</div>
<div id="copy" class="copy4">
Test text _04
</div>
jQuery -----
function slideDownFunc() {
if(jQuery("#copy.copy1")){
if (jQuery("#copy.copy1").is(":hidden")) {
jQuery("#copy.copy1").stop().slideUp("medium");
}
}else if(jQuery("#copy.copy1")){
jQuery("#copy.copy1").stop().slideUp("medium");
}
};
function slideUpFunc() {
if(jQuery("#copy.copy2")){
if (jQuery("#copy.copy2").is(":visible")) {
jQuery("#copy.copy2").stop().slideDown("medium");
}
}else if(jQuery("#copy.copy2")){
jQuery("#copy.copy2").stop().slideDown("medium");
}
};
jQuery("#main1.rollOver_1").mouseover(function(){
slideDownFunc();
}).mouseout(function(){
slideUpFunc();
});
jQuery("#main1.rollOver_2").mouseout(function(){
slideDownFunc();
}).mouseout(function(){
slideUpFunc();
});
CSS ----------
.rollOversHolder {
width:710px;
height:135px;
border:#CCCCCC 1px solid;
}
#main1 {
background:url(../images/it_sol_norm.png);
width:103px;
height:133px;
float:left;
}
.emptyCopyClass {
width:230px;
height:150px;
position:relative;
color:#4d4d4d;
border:1px solid red;
}
#copy {
width:230px;
height:150px;
position:relative;
display:none;
color:#4d4d4d;
}
First up... Thank-you in advance!
I have 4 divs.
When each div is rolled-over i want divs with unique text to appear within another div that has a class name of '.rollOversHolder'
The text divs all contain an id of '#copy' but all have unique class names eg. '.copy1', '.copy2' etc
I want the '#copy' divs to be individually displayed within the '.rollOversHolder' div and when another button is rolled over i want to current animation to stop and the new one begin.
HTML ---
<div class="rollOversHolder">
<div id="main1" class="rollOver_1"></div>
<div id="main1" class="rollOver_2"></div>
<div id="main1" class="rollOver_3"></div>
<div id="main1" class="rollOver_4"></div>
</div>
<div class="emptyCopyClass"></div>
<div id="copy" class="copy1">
Test text _01
</div>
<div id="copy" class="copy2">
Test text _02
</div>
<div id="copy" class="copy3">
Test text _03
</div>
<div id="copy" class="copy4">
Test text _04
</div>
jQuery -----
function slideDownFunc() {
if(jQuery("#copy.copy1")){
if (jQuery("#copy.copy1").is(":hidden")) {
jQuery("#copy.copy1").stop().slideUp("medium");
}
}else if(jQuery("#copy.copy1")){
jQuery("#copy.copy1").stop().slideUp("medium");
}
};
function slideUpFunc() {
if(jQuery("#copy.copy2")){
if (jQuery("#copy.copy2").is(":visible")) {
jQuery("#copy.copy2").stop().slideDown("medium");
}
}else if(jQuery("#copy.copy2")){
jQuery("#copy.copy2").stop().slideDown("medium");
}
};
jQuery("#main1.rollOver_1").mouseover(function(){
slideDownFunc();
}).mouseout(function(){
slideUpFunc();
});
jQuery("#main1.rollOver_2").mouseout(function(){
slideDownFunc();
}).mouseout(function(){
slideUpFunc();
});
CSS ----------
.rollOversHolder {
width:710px;
height:135px;
border:#CCCCCC 1px solid;
}
#main1 {
background:url(../images/it_sol_norm.png);
width:103px;
height:133px;
float:left;
}
.emptyCopyClass {
width:230px;
height:150px;
position:relative;
color:#4d4d4d;
border:1px solid red;
}
#copy {
width:230px;
height:150px;
position:relative;
display:none;
color:#4d4d4d;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
更新
我已将 rollOversHolder 设置为环绕悬停副本,将相同的尺寸设置为一个可悬停内容集。将所有项目设置为绝对位置,以便动画可以在 1 个设定位置上发生。在动画上,我设置 z-index 以显示相对内容。
检查以下内容:http://jsfiddle.net/aP2r3/8/
HTML
Jquery
请告诉我这是否适合您。
更新[点击事件]
您可以看看这个:http://jsfiddle. net/aP2r3/9/
对于点击事件,请参阅我的以下代码(您可以更改类名以使其更相关)
Jquery :
Update
I have set the rollOversHolder to wrap around hover copy, set same dimensions to one hover-able content set. Set all items to position absolute so that animation can occur on 1 set location. on animation i am setting the z-index to show relative content.
Check the following: http://jsfiddle.net/aP2r3/8/
HTML
Jquery
Please let me know if this is working for you.
UPDATE [click event]
You can have a look at this : http://jsfiddle.net/aP2r3/9/
For a click event, see my following code (You can just change the class names to be more relevant)
Jquery :