weixin_33722405 2012-12-25 02:22 采纳率: 0%
浏览 59

jQuery AJAX加载IE6问题

I have a main HTML file with all the jQuery and JavaScript files included in it. Now I have a table which has a expand/collapse functionality. This table is in a different HTML file.

I am trying to load the table in the main file. I was successful in loading the table in the main HTML file but the expand/collapse is not working only in IE6/IE7. This works fine in FF, Chrome, Safari and IE8.

local.js has the expand/collapse code
table.html is the html file which has only the table code and no JavaScript.

MAIN HTML:

<html>
    <title>Main html</title>
    <head>
        <script type="text/javascript" src="jquery.js"></script>
        <script type="text/javascript" scr="localjs.js"></script>
        <script type="text/javascript">

            $('#ajaxtable').load('ajax/table.html', function() {
                alert('Table Loaded.');
            });

        </script>
    </head>

    <body>
        <div id="ajaxtable"></div>
    </body>
</html>

I can see the table gets loaded in the ajaxtable div but the expand/collapse is not working only in IE6.

  • 写回答

1条回答

  • weixin_33670786 2012-12-25 02:59
    关注

    As I mentioned in my comment above, you are loading localjs.js before the $('#ajaxtable') call. Attach the click handler after the table has been created and you should be fine...

    <script type="text/javascript">
    $('#ajaxtable').load('ajax/table.html', function() {
      alert('Table Loaded.');
      $('table tr.heading').click(function(){ $(tr.alpha).slideToggle('slow'); });
    });
    </script>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog