简体   繁体   中英

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.

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

$('#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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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