我是网络编程的新手,所以请原谅。
我的 index.html 文件中有一个 div,它是空的。
<div id='menu1'  >
</div><!--/.well -->
基于菜单项点击,我在 div 中加载 html 文件。
$('#menu1').load('gallery.html')
因此,gallery.html 有 twitter 引导示例轮播,但它没有被加载,但是如果我将代码直接粘贴到 index.html 的“menu1”div,一切似乎都正常。
任何建议都会有所帮助。
编辑***我的 js [调用滑块的加载]
$(document).ready(function() {
            //$('#menu1').load('home.html')
            $("li").click(function(){
          // If this isn't already active
          if (!$(this).hasClass("active")) {
            // Remove the class from anything that is active
            $("li.active").removeClass("active");
            // And make this active
            $(this).addClass("active");
        }
    });
            $('ul li a').live('click', function() {
                var clickid = $(this).parent('li').index();
                var myid = $(this).attr('id');
                $('#menu1').html(" ");
                $('#slider').css('display','none');
                switch (myid)
                {
                    case "home":
                    $('#slider').css('display','block');
                    break;
                    case "aboutus":
                    $('#menu1').load('aboutus.html')
                    break;
                                case "gallery":
                    $('#menu1').load('gallery.html')
                    break;
                };
    //alert(myid);
                //alert(clickid);
            });
        });
编辑**gallery.html的html代码[我正在谈论的滑块]
<div id = "myCarousel" class="carousel">
    <!-- Carousel items -->
    <div class="carousel-inner">
      <div class="item active">
        <img src="../photos/1.jpg" alt="">
          <div class="carousel-caption">
            <h4>Super sweet bathroom</h4>
            <p>This bathroom is truly incredible</p>
          </div>
      </div>
      <div class="item">
        <img src="../photos/2.jpg" alt="">
        <div class="carousel-caption">
          <h4>OK, maybe this bathroom is better</h4>
          <p>This beautiful bathroom could be yours - just call Price Builders today.</p>
        </div>
      </div>
      <div class="item">
        <img src="../photos/3.jpg" alt="">
        <div class="carousel-caption">
          <h4>Not even sure what this is</h4>
          <p>Go figure</p>
        </div>
      </div>
    </div>
  </div>
    <!-- Carousel nav -->
  <a class="carousel-control left" href="#myCarousel" data-slide="prev">‹</a>
  <a class="carousel-control right" href="#myCarousel" data-slide="next">›</a>
  </div>
来自gallery.html的图像滑块被加载但它不起作用..我无法移动图像..但是如果我将代码移动到index.html而不使用js加载,同样的工作原理