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

jQuery show and hide in developer tool and in $(document).ready() function it is working fine but in re

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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745541087a4632131.html

相关推荐

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

    jQuery show and hide in developer tool and in $(document).ready() function it is working fine but in re

    13小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信