所以在我的 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 并且成功了。为什么 SlideUp 和 fadeOut 不起作用?难道是我使用不当?
最佳答案
关于javascript - JQuery 滑动和淡出 'not working' ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19286689/