想要在使用jQuery的click事件时将2个函数分配给按钮,它将如下工作:当单击按钮时,我有一个隐藏在另一个div后面的div使用jQuery滑动div来设置动画效果...此#show ID显示div,ID #hide隐藏div,如何为同一个按钮分配2个不同的ID?我已经做到了这一点使用ID属性和attR ...改为#hide,但联系到该ID的功能不performedry使用jQuery更改元素ID不适用于我的功能
HTML:
<div class="content"></div>
<div class="footer"></div>
<div class="hiddendiv">
<a href="#" id="show">show</a>
</div>
CSS:
.content {
height: 400px;
}
.footer {
display: inline-table;
background: #ff8;
width: 100%;
height: 80px;
position: relative;
top: 0;
bottom: 0;
left: 0;
right: 0;
z-index: 2;
}
.hiddendiv {
width: 500px;
height: 300px;
background: #252525;
position: relative;
z-index: 1;
top: -120px;
margin: 0 auto;
}
.hiddendiv a {
color: #000;
font-size: 15px;
font-family: sans-serif;
text-decoration: none;
padding-top:5px;
padding-bottom:5px;
padding-left: 20px;
padding-right: 20px;
background: #eee;
border-radius: 10px;
box-shadow: inset 0px 1px 20px 0px #333;
}
.hiddendiv a:hover {
color: #f0f;
}
JQUERY:
$("#show").click(function() {
$(".hiddendiv").animate({
top: "-=250"
}, "slow");
$("#show").attr("id", "hide");
});
$("#hide").click(function() {
$(".hiddendiv").animate({
top: "+=250"
}, "slow");
$("#hide").attr("id", "show");
});
你不能指定两个ID到一个HTML元素,然而,你可以分配多个类 –
再次尝试类,它似乎只是第一类 –