jquery hide,显示不在chrome中工作

时间:2014-05-29 07:19:28

标签: javascript jquery css google-chrome

jQuery显示并隐藏在开发人员工具和$(document).ready()函数中它工作正常,但在常规程序流程中它无法在expandTreeNode()函数中运行。

问题仅出在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;
}

提前致谢。

2 个答案:

答案 0 :(得分:4)

基本上.show().hide()没有任何参数会充当synchronous一个,所以请尝试

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

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

答案 1 :(得分:0)

可能是在将#loading_msg对象加载到DOM之前执行了您的JavaScript代码。如果在html head部分声明此函数,请尝试将其移动到页面底部,或者只在$(document).ready()函数之间移动函数。

相关问题