最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - jquery hide, show not working in chrome - Stack Overflow

programmeradmin2浏览0评论

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.

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.

Share Improve this question edited May 29, 2014 at 7:21 George 36.8k9 gold badges69 silver badges109 bronze badges asked May 29, 2014 at 7:19 KumarKumar 2751 gold badge4 silver badges12 bronze badges 3
  • 1 what is //some code here ? is it some kind of async function? – zzlalani Commented May 29, 2014 at 7:22
  • First, in your document.ready, put $('#loading_msg').show();. If you able to see it, i means it has no problem on show – jhyap Commented May 29, 2014 at 7:26
  • 1 @Kumar: I was facing the same issue, if in your code async=false then make it true. It would work in both - firefox as well as in chrome. – Domain Commented Oct 22, 2015 at 7:28
Add a ment  | 

2 Answers 2

Reset to default 4

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.

发布评论

评论列表(0)

  1. 暂无评论