Jquery 使用幻灯片切换时添加和删除css

Jquery 使用幻灯片切换时添加和删除css,jquery,codeigniter,Jquery,Codeigniter,如何在使用幻灯片向下时添加css“display:inline”,在使用幻灯片向上时添加css“display:none”? 我已经使用了下面的代码 echo '<br>'; echo '<span>'; echo '<div id="paris" style="width:380px;">'; echo translate('par

如何在使用幻灯片向下时添加css“display:inline”,在使用幻灯片向上时添加css“display:none”? 我已经使用了下面的代码

                echo '<br>';
                echo '<span>';
                echo '<div id="paris" style="width:380px;">';
                echo translate('paris top');
                echo '<div style="display: none;">';
                echo translate('paris top second');
                echo '</div>';
                echo '<a href="#" class="readmore_paris">';
                echo "...See More";
                echo '</a>';
                echo '</div>';

            $('.readmore_paris').click(function(e){
                 e.preventDefault();
                 $('#paris div').slideDown(function () {
                       $("#paris div").css({display: "inline"});
                 });
                 $('#paris div').slideUp(function () {
                       $("#paris div").css({display: "none"});
                 });
                  $(this).text( $(this).text() == '...See More' ? "Show Less" : "...See More");
             });
echo'
'; 回声'; 回声'; echo translate(“巴黎顶级”); 回声'; echo translate(“巴黎排名第二”); 回声'; 回声'; 回声'; $('.readmore_paris')。单击(函数(e){ e、 预防默认值(); $('#巴黎分区')。向下滑动(函数(){ $(“#巴黎分区”).css({display:“inline”}); }); $('#巴黎分区')。幻灯片(函数(){ $(“#巴黎分区”).css({display:“none”}); }); $(this).text($(this.text()==“…查看更多信息?”?“显示较少”:“…查看更多信息”); });
只需使用

$("#paris div").toggle();

它将交替显示和隐藏元素……

这似乎达到了您可能期望的效果

$('.readmore_paris').click(function(e){
     e.preventDefault();
     $('#paris div').slideToggle();
     $(this).text( $(this).text() == '...See More' ? "Show Less" : "...See More");
});

如果需要显示div:inline,而不是block

$('.readmore_paris').click(function(e){
     e.preventDefault();
     $('#paris div').slideToggle(function () {
         if ($(this).is(':visible')){
             $(this).css({display: 'inline'});
         }
     });
     $(this).text( $(this).text() == '...See More' ? "Show Less" : "...See More");
});

当前代码有什么不起作用?向上滑动滑动切换时显示“无”不起作用,如我的回答所示。我允许将其内联,而不是默认块请澄清,在向上滑动之前,您不想隐藏它。或者这就是你想要的,让它消失,下面的东西向上移动?或者你的意思是你需要在动画制作时将其内联?这个问题很不清楚,是的。但是第二个div不是内联的。它切换为单独的div。因此,不需要的空间显示在第一个divRE附近:
{display:
vs
{“display”:
,对象的键可以封装,它不会更改对象,当它们不更改时,这不是语法错误。唯一的问题是当键与某个对象冲突时,例如
{class:'foo'}
中断IE。