javascript - 在页面加载时隐藏 div

标签 javascript jquery html css

我有两个“ul”列表。使用 javascript a 从第二个列表中删除子项并添加到第一个 ul 列表中。但是当页面加载时,第二个菜单看起来没有样式。见hereweb

这是代码。 #main-menu 和#section menu 是 ul 列表:

//dinamyc main menu
    if( $('body').hasClass('page-template-templateshome-page-php') ){
        $('#section_menu').children().each(function(i, e){
            var firstLi = '#' + $('.navbar').next().attr("id");
            $('.home .menu-item-home a').removeClass('external').attr( "href", firstLi );

            if($('#main-menu div ul li').is($(e).insertAfter('#main-menu ul li:eq(0)'))){
                $(e).insertAfter('#main-menu ul:eq(0)');
            }

            $('#section_menu').css('display','none');

        });
    }else{
        $('#section_menu ').children().remove();
        $('#section_menu').remove();
    }

CSS:

#section_menu { display:none; }

最佳答案

<div id="hidden-during-page-load">Loading...</div>

$(window).load(function(){
  // this will ensure that all content has loaded before the div is shown
  $("#hidden-during-page-load").show();
});

#hidden-during-page-load {
    display:none;   
}

关于javascript - 在页面加载时隐藏 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22234219/

相关文章:

javascript - v-for 和状态管理问题

javascript - SimulatedGreg Electron-Vue-Vuetify错误消息: [Vue warn]: Unknown custom element: <v-app> - did you register the component correctly?

javascript - 在 Winston 日志框架中实现 Promise

jquery - html页面加载后文本消失

HTML 范围样式 firefox。让拇指在边缘居中

javascript - 如果 span 包含文本,则更改 div css

javascript - 在 javascript 和 jquery 中使用原型(prototype)函数中构造函数中传递的变量

javascript - 如何在ajax调用后重新加载img attr "src"而不知道图像标签中的文件名?

javascript - Jquery 自定义照片幻灯片同时显示所有图像而不是一个然后下一个

jquery - Susy 响应式网格和 jQuery Masonry