当单击图像时,我想在另一个旁边切换一个 div。当它切换打开时,它应该将旁边的 div 推到左侧。当切换关闭 div 时,它会移回它的位置......它现在所做的是在它旁边的 div 顶部切换。这是我的代码。
img{
margin-left:0px;
}
#info {
position: absolute;
margin-left: 20px;
margin-top: -310px;
border: 1px solid black;
width: 400px;
height: 308px;
background-color: #F4F4EE;
}
#container {
border: 1px solid black;
position: relative;
}
jQuery...
$(document).ready( function(){
hideInfo();
});
function hideInfo(){
$( '#container > div' ).hide();
$('#container a').click(function(){
$(this).next().animate({
width: "toggle",
height: "toggle"},
{duration: 700,
specialEasing: {width: "linear"},
});
});
}
html
<body>
<div id="container">
<a href="#"><img src="button.jpg"/></a> /*image must be clicked to toggle the div */
<div id="info" class="panel">
Information in div 1
</div>
<a href="#"><img src="button2.jpg"/></a
<div id="info" class="panel">
information in the second div
</div>
<div>
</body>