jQuery slideToggle函数的问题

时间:2015-08-19 00:56:55

标签: javascript jquery html css slidetoggle

请帮助我找到此代码的问题。我正在尝试创建一个简单的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>

1 个答案:

答案 0 :(得分:0)

&#13;
&#13;
    $(document).ready(function(){
      $('#toggle').animate({ height : 'toggle' });
         $("#Layer13copy2").click(
    	 function(){$('#toggle').animate({ height : 'toggle' });
    });});
&#13;
     #Layer13copy2 
    { 
    	 position: absolute; 
    	 width: 292px;
    	 height: 37px;
    	 background-color:blue;
    	 } 
    #toggle{
        background-color: #3a97b1;
        top: 35px;
        position: absolute;
        width: 100%;
        height: 100px;
    }
&#13;
<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>
&#13;
&#13;
&#13;