如何在divFirst之前加载divSecond?

时间:2015-03-06 16:25:28

标签: javascript jquery

假设divSecond低于divFirst。我想在divFirst之前使用JavaScript来进行divSecond加载。

+------------+
|            |
|  divFirst  |
|            |
|  content   |
|            |
| divSecond  |
|            |
+------------+

我已经得到了以下代码,但我无法弄清楚如何检查。

jQuery(document).ready(function() {
    checkDiv();
});

function checkContainer () {
    if($('#divSecond').is(':visible'))){ 
    // If it's loaded
    // How to load it in the page..
}

1 个答案:

答案 0 :(得分:0)

$(function() {
    $("#divFirst").hide();
    // Hiding it by default. better use CSS selector this purpose so that it won't be shown. 
    // #divFirst {display: none;}

    checkDiv();
});

假设您只在divFirst可见/显示

时才显示divSecond
function checkContainer () {
    if($('#divSecond').is(':visible')){ 
        $("#divFirst").show();
    });
}
相关问题