问题滑入/滑出JQuery

| 滑出是没有问题的,我只有滑入的问题才不会出现,我认为它没有抓住他们的第一个IF宽度等于0px的问题。对不起,我真的对jQuery没什么看法。 码:
<script src=\"http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js\" type=\"text/javascript\"></script>
<script type=\"text/javascript\">
$(document).ready(function(){
    $(\"#ShowHideComment\").click(function(){
        if ($(\".iframe_comment\").width() == \"0px\"){
            $(\".iframe_comment\").animate({width: \"800px\"}, {queue:false, duration:1000});
        }
        else{
            $(\".iframe_comment\").animate({width: \"0px\"}, {queue:false, duration:1000
           });
        }
    });
});
</script>
    
已邀请:
从文档:   所有动画属性应设置为单个数值 您不在这里处理CSS属性值,而是在使用纯整数。
$(document).ready(function(){
    $(\"#ShowHideComment\").click(function(){
        var $comment = $(\".iframe_comment\");
        if ($comment.width() == 0){
            $comment.animate({width: 800}, {queue:false, duration:1000});
        }
        else{
            $comment.animate({width: 0}, {queue:false, duration:1000});
        }
    });
});
另请参阅
width()
:   
.css(width)
和有什么区别   
.width()
是后者   返回无单位像素值     
.width()
返回数值。 这条线
if ($(\".iframe_comment\").width() == \"0px\")
应该
if ($(\".iframe_comment\").width() == 0)
    

要回复问题请先登录注册