jQuery slideToggle 函数的问题
Problems with jQuery slideToggle Function
请帮我找出这段代码的问题。我正在尝试创建一个简单的 slideToggle 元素!我首先尝试了这个:
$("..").slideToggle(..,..,..)
我当前的代码如下所示:
我的代码:
$(document).ready(function () {
$("#Layer13copy2").click(function () {
$("#toggle").animate({ height: 'toggle' });
});
});
#Layer13copy2 {
left: 13.85%;
top: 398px;
position: absolute;
width: 892px;
height: 37px;
z-index:5;
background:url('../images/slidet.png') 45%;
background-repeat:no-repeat;
background-size:101.4% 101%;
}
#toggle {
z-index: 4;
background-color: #3a97b1;
display: block;
left: 13.85%;
top: 39.37%;
position: absolute;
width: 71.95%;
height: 17%;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<div id="Layer13copy2"></div>
<div id="toggle"></div>
$(document).ready(function(){
$('#toggle').animate({ height : 'toggle' });
$("#Layer13copy2").click(
function(){$('#toggle').animate({ height : 'toggle' });
});});
#Layer13copy2
{
position: absolute;
width: 292px;
height: 37px;
background-color:blue;
}
#toggle{
background-color: #3a97b1;
top: 35px;
position: absolute;
width: 100%;
height: 100px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<div id="Layer13copy2" >
<div id="toggle" marginwidth="0"></div>
</div>
请帮我找出这段代码的问题。我正在尝试创建一个简单的 slideToggle 元素!我首先尝试了这个:
$("..").slideToggle(..,..,..)
我当前的代码如下所示:
我的代码:
$(document).ready(function () {
$("#Layer13copy2").click(function () {
$("#toggle").animate({ height: 'toggle' });
});
});
#Layer13copy2 {
left: 13.85%;
top: 398px;
position: absolute;
width: 892px;
height: 37px;
z-index:5;
background:url('../images/slidet.png') 45%;
background-repeat:no-repeat;
background-size:101.4% 101%;
}
#toggle {
z-index: 4;
background-color: #3a97b1;
display: block;
left: 13.85%;
top: 39.37%;
position: absolute;
width: 71.95%;
height: 17%;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<div id="Layer13copy2"></div>
<div id="toggle"></div>
$(document).ready(function(){
$('#toggle').animate({ height : 'toggle' });
$("#Layer13copy2").click(
function(){$('#toggle').animate({ height : 'toggle' });
});});
#Layer13copy2
{
position: absolute;
width: 292px;
height: 37px;
background-color:blue;
}
#toggle{
background-color: #3a97b1;
top: 35px;
position: absolute;
width: 100%;
height: 100px;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<div id="Layer13copy2" >
<div id="toggle" marginwidth="0"></div>
</div>