だから私のJavascriptでは、私はこれを持っています
$('ul li').click(function(){ //loops through all <li>'s inside a <ul>
$('ul .clicked').removeClass('clicked'); // when an <li> is clicked, remove .clicked class from any other <li>'s
$(this).addClass('clicked'); // add .clicked class to the clicked <li> ($(this))
$(this).screenSlide();
});
さて、screenSlide機能はこちら
$.fn.screenSlide = function(){ // $(this) = aboutSectorNineteen (<li>'s id)
var test = $('.current').attr('id'); //if an element with .current as it's class exists, let test be equal to that elements id
test = "#" + test;
$(test).slideUp(); // slide it up, hide it and remove the .current class from the <li> element
$(test).hide();
$(test).removeClass('current');
var gettingShown = $(this).attr('id');
gettingShown = "#" + gettingShown + "Slide";
$(gettingShown).addClass('current'); // add the .current class to $(this) <li>
$(gettingShown).slideDown();
};
これで、gettingShown が上にスライドし、別の < li > をクリックすると、上にスライドした画面 (gettingShown) が非表示になりますが、上にスライドしません。つまり、
$(test).hide();
しかし働いている
$(test).slideUp();
機能していませんよね?何故ですか?また、slideUp を fadeOut に変更しようとしましたが、それでもうまくいきませんでした。私はslideDownをfadeInに変更しましたが、うまくいきました。スライドアップとフェードアウトが機能しないのはなぜですか? 私はそれを間違って使用していますか?