简体   繁体   English

jQuery隐藏,显示无法在Chrome浏览器中工作

[英]jquery hide, show not working in chrome

jQuery show and hide in developer tool and in $(document).ready() function it is working fine but in regular flow of program its not working in expandTreeNode() function. jQuery在开发人员工具和$(document).ready()函数中显示和隐藏,效果很好,但是在程序的常规流程中, expandTreeNode()函数不起作用。

Problem is only in chrome. 问题仅在于铬合金。

$(document).ready(function(){
    $('#loading_msg').hide();
});


//not working
function expandTreeNode(item) {

    if (item.p.postData.nodeid == undefined)
        return true;

    $('#loading_msg').show();

    //some code here

    $('#loading_msg').hide();
    return false;
}

Thanks in advance. 提前致谢。

Basically .show() and .hide() without any parameters would act as synchronous one, so try 基本上.show().hide()不带任何参数将作为synchronous一个,所以尽量

$('#loading_msg').show('slow');

$('#loading_msg').hide('slow');

It may be that your JavaScript code is executed before #loading_msg object has been loaded to DOM. 您的JavaScript代码可能是在#loading_msg对象已加载到DOM之前执行的。 If you declare this function in your html head section try to move it to the bottom of the page or just move the function between $(document).ready() function. 如果您在html头部分中声明了此函数,请尝试将其移至页面底部,或者仅在$(document).ready()函数之间移动该函数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM