weixin_33728708 2015-03-15 03:03 采纳率: 0%
浏览 29

加载div中的jQuery选项卡

Simple Jquery Tabs does not work in "loaded" div.

  • Originally had jquery in the external file.
  • ajax rules nullify script in the external html on load.
  • removed script from external html
  • attempting to execute tabs through callback on load function.
  • verified that tabs works on html in the index page, not on loaded html.

Contents of Index page:

<!DOCTYPE html>
<html>
<head>
<title>BSP</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!--[if lte IE 8]>
<script type="text/javascript" src="js/mootools.js"></script>
<script type="text/javascript" src="js/selectivizr.js"></script>
<![endif]-->
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/smoothness/jquery-ui.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script>
<script src="jquery.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" href="stylesheet.css">

<script>
$(document).ready(function(){ 
    //Format Accordion
    $(function() {
        $( "#accordion" ).accordion({
          heightStyle: "content",
              active: false,
              collapsible: true
        });
    });

    //Collapse accordion on resize
    $(window).resize(function () {
    $('#accordion').accordion("option", "active", false);
    });

    //load selection and format tabs
    $(function() {
        var work = $( "#display" );
        $( "#selector" ).change(function( event ) {
            work.load($(this).val(),function(){
                 $("#textdisplay").tabs();
            });
        });
    });

});
</script>
</head>
<body>
    <div id="accordion">
         <H3>BSP</H3>
            <div id="biomaster"> <?php include 'bio/bio.html';?></div>
         <H3>Collection of Works</H3>
        <div>
            <select name="selector" id="selector">
                <option value="Works">Works</option>
                <option value="blood/blood.html">Flesh and Blood</option>
                <option value="grace/grace.html">Grace</option>
                <option value="gears/gears.html">Switching Gears</option>
                <option value="love/love.html">Love Song</option>
                <option value="redemption/redemption.html">Redemption</option>
                <option value="way/way.html">The Way</option>
            </select>
            <div>
                <div id="display"></div>
            </div>
        </div>      
    </div>
</body>
</html>

Contents of Loaded HTML:

<html>
<head>
</head>
<body>
<div class="audiobar" >
    <audio controls>
      <source src="blood/blood.mp3" type="audio/mpeg" id="bloodmp3">
    Your browser does not support the audio element.
    </audio>
</div>
<div id="textdisplay">
  <ul>
    <li><a href="#Lyrics">Lyrics</a></li>
    <li><a href="#Reflections">Reflections</a></li>
  </ul>
  <div id="Lyrics">
    <p>Lyrics</p>
  </div>
  <div id="Reflections">
    <p>Reflections</p>
  </div>
</div>
</body>
</html>
  • 写回答

1条回答 默认 最新

  • YaoRaoLov 2015-03-15 03:05
    关注

    try below code. you can read more about callback function using jquery load()

    dsp.load("loaded.html",function(){
       $( "#textdisplay" ).tabs();
    });
    

    Do not include html, head, or body tags in your "loaded" html file. - These will conflict with your index page and kill your script.

    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥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,如何解決?