<script type="text/javascript" src="http://www.codefans.net/ajaxjs/jquery1.3.2.js"></script>
<style type="text/css">
.text{line-height:22px;padding:0 6px;color:#666;}
.box h3{padding-left:10px;height:22px;line-height:22px;background:#f1f1f1;font-weight:bold;}
.box{position:relative;border:1px solid #e7e7e7;}
</style>
<script type="text/javascript">
$(document).ready(function(){
   $(".box h3").toggle(function(){
     $(this).next(".text").animate({height: 'toggle', opacity: 'toggle'}, "slow");
   },function(){
$(this).next(".text").animate({height: 'toggle',opacity: 'toggle'}, "slow");
   });
});
</script>
帮忙看一下这一小段脚本。修改哪个属性就可以让层在页面加载的时候收缩??

解决方案 »

  1.   

    很简单,
    .text{line-height:22px;padding:0 6px;color:#666;display:none;}这样就行了,另外jQuery的toggle说明:
    toggle(fn,fn)
    每次点击时切换要调用的函数。
    如果点击了一个匹配的元素,则触发指定的第一个函数,当再次点击同一元素时,则触发指定的第二个函数。随后的每次点击都重复对这两个函数的轮番调用。可以使用unbind("click")来删除。
    --------------------------------------------------------------------------------Toggle between two function calls every other click.
    Whenever a matched element is clicked, the first specified function is fired, when clicked again, the second is fired. All subsequent clicks continue to rotate through the two functions.Use unbind("click") to remove.返回值
    jQuery参数
    fn (Function) : 第奇数次点击时要执行的函数。fn (Function) : 第偶数次点击时要执行的函数。示例
    对表格的切换一个类 jQuery 代码:$("td").toggle(
      function () {
        $(this).addClass("selected");
      },
      function () {
        $(this).removeClass("selected");
      }
    ); 别再说世态严凉啊,哈哈。另外有些东西可以给你参考下啊,http://www.woiweb.net/33-jquery-examples.html