我有一个设置菜单,在页面加载时显示,它有一个按钮,通过添加类"隐藏"并删除" showup"显示它时反之亦然。
我只想在2分钟后最小化菜单,以防有人没有点击按钮。
我的问题是,当我这样做时
if ($(".hidedown").length > 0 ) {
//hidedown class is present
} else {
//hidedown class is not present
}
我总是得到"隐藏课程不存在"甚至当班级"隐藏"在那里
/* so i have this function */
/* minimize the floating menu after 2mins */
window.setTimeout(function() {
if ($(".hidedown").length > 0) { /* i don knw why this is not working */
console.log("the menu should minimize");
$(".settings_link, .companies").animate({
left: "-=165"
}, 700, function() {});
$(this).html('<i class="fa fa-bars"></i>').removeClass("hidedowm").addClass("showup");
} else {
console.log("class 'hidedown' is not there!");
/* i get this even when the class is there */
}
}, 1000);
/* this will hide the settings/companies menu */
$(document).on("click", ".settings_link.showup", function() {
$(".settings_link, .companies").animate({
left: "+=165"
}, 700, function() {});
$(this).html('<i class="fa fa-bars"></i>').removeClass("showup").addClass("hidedowm");
});
/* this will show the settings/companies menu */
$(document).on("click", ".settings_link.hidedowm", function() {
$(".settings_link, .companies").animate({
left: "-=165"
}, 700, function() {});
$(this).html('<i class="fa fa-bars"></i>').removeClass("hidedowm").addClass("showup");
});