JQuery 幻灯片向上和淡出“不起作用”
JQuery slideUp and fadeOut 'not working'?
所以在我的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();
});
现在,屏幕幻灯片功能是这样的
$.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();
};
现在,gettingDisplay确实向上滑动,当我单击另一个
$(test).hide();
但是正在工作
$(test).slideUp();
不行吧?为什么?我还尝试将 slideUp 更改为淡出,但这仍然不起作用。我将幻灯片更改为淡入,它起作用了。为什么幻灯片和淡出不起作用?我用错了吗?
slideUp(( 是异步的,它在完成向上滑动时隐藏元素。
它应该是
$(test).slideUp(function () {
$(this).removeClass('current');
});
这是绑定事件和操作的更简洁版本。
$('ul > li').click(function() { //loops through all <li>'s inside a <ul>
$('li').removeClass('clicked'); // when an <li> is clicked, remove .clicked class from any other <li>'s
$(this).addClass('clicked').screenSlide(); // add .clicked class to the clicked <li> ($(this))
});
$.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).slideUp().removeClass('current'); // slide it up, hide it and remove the .current class from the <li> element
};
相关文章:
- 添加/删除类淡入淡出不起作用
- 淡入淡出脚本不起作用
- 纯 JavaScript 淡入淡出 - 淡入不起作用
- 淡入淡出链接悬停不起作用
- 淡出加载然后淡入不起作用
- jQuery图像淡入淡出不起作用
- jQuery父对象(“tr”)淡出不起作用
- 淡入淡出和AppendTo不起作用-jQuery
- jquery 和 safari 7 - slide切换和淡入淡出切换不起作用
- function(){如果淡出,则追加}不起作用
- 淡入淡出 JavaScript 中的图像不起作用
- 为什么这种淡出不起作用
- JQuery 幻灯片向上和淡出“不起作用”
- 淡入和淡出功能不起作用
- 淡入/淡出功能不起作用
- 淡出功能在所有浏览器中都不起作用
- 为什么这种淡入淡出效果不起作用
- jquery淡出并重定向在IE中不起作用
- 淡入淡出css动画不起作用
- Ajax.BeginForm淡出不起作用