【问题标题】:jquery call function after load html content加载html内容后的jquery调用函数
【发布时间】:2012-02-03 05:27:12
【问题描述】:

假设我有 2 个 html 文件

index.html

<html>
    <div id="content"></div>
    <div id="footer"></div>
    <script>
        $("#content").load("productos.html");
        $("#footer").load("pie.html");
    </script>
</html>

productos_main.html

<html>
...
<div id="prod_fabricantes" class="optbar">fabricantes</div>
<div id="prod_industria" class="optbar">industria</div>
<div id="prod_header"></div>
<div id="prod_mainframe"></div>
...
<script>
$('#prod_fabricantes').live('click', function() {
    document.title = '..:: TITLLE :: Productos :: Fabricantes';
    $("#prod_header,#prod_mainframe").empty();
    $("prod_header").text("Text for Fabricantes's section");
    $('#prod_mainframe').load("prod_fabricantes.html");

});
$('#prod_industria').live('click', function() {
    document.title = '..:: TITLLE :: Productos :: Industria';
    $("#prod_header,#prod_mainframe").empty();
    $("prod_header").text("Text for Industria's section");
    $('#prod_mainframe').load("prod_industria.html");

});
</script>
</html>

pie.html

<html>
<div id="map syte">
<table class="table_site">
<tr>
<td id="st_fab" class="topsite">Fabricantes</td>
<td id="st_ind" class="topsite">Industria</td>
</tr>
</table>

<script>
$('#st_fab').live('click', function(){
    $('#content').empty();
    document.title = '..:: DIELECSUR S.L :: Productos :: Fabricantes';
    $("#content").load("productos_main.html");
    $("#prod_header,#prod_mainframe").empty();
    $("prod_header").text("Text for Fabricantes's section");
    $('#prod_mainframe').load("prod_fabricantes.html");
});
$('#st_ind').live('click', function(){
    $('#content').empty();
    document.title = '..:: DIELECSUR S.L :: Productos :: Idustria';
    $("#content").load("productos_main.html");
    $("#prod_header,#prod_mainframe").empty();
    $("prod_header").text("Text for Industria's section");
    $('#prod_mainframe').load("prod_industria.html");
});
...
</html>

我在页脚部分使用站点地图加载内容时遇到问题。 事件 onclick 页脚选项 1.点击#st_fab 2.它将productos_main.html加载到#content div 3.if会执行$('#st_fab').live('click', function() { ... });下面的函数

错误

它只将productos_main.html加载到#content div中

请帮忙

【问题讨论】:

    标签: jquery function load


    【解决方案1】:

    试试:

    $("#content").load("productos.html", function() { $("#footer").load("pie.html"); });

    【讨论】:

      【解决方案2】:

      您是否尝试过将 .load 事件放入函数中并使用:

      function mainFrameLoad(strHTMLFile){
          $(document).ready(function($){
              $('#prod_mainframe').load(strHTMLFile);
          });
       }
      

      【讨论】:

        猜你喜欢
        • 2017-03-10
        • 1970-01-01
        • 2012-09-26
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多