Jquery 获得';无法读取属性';网间距';未定义引导的定义

Jquery 获得';无法读取属性';网间距';未定义引导的定义,jquery,twitter-bootstrap,Jquery,Twitter Bootstrap,我得到了未定义的offsetwidth,尽管添加了活动类,并在js函数的正上方定义了jquery。我不得不用旋转木马来做我的工作,我试着用一个模拟的来练习。我的第一个活动图像正在显示,单击“下一步”后,我在控制台中出现此错误,图像不会滑动 <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8"> <meta h

我得到了未定义的
offsetwidth
,尽管添加了活动类,并在js函数的正上方定义了jquery。我不得不用旋转木马来做我的工作,我试着用一个模拟的来练习。我的第一个活动图像正在显示,单击“下一步”后,我在控制台中出现此错误,图像不会滑动

  <!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">

  <title>mycooking</title>

</head>
<body>
  <!--indicatiors-->
  <div class="container">
    <div class="row-fluid">
      <div id="myCarousel" class="carousel slide" data-ride="carousel">
        <ol class="carousel-indicators">
          <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
          <li data-target="#myCarousel" data-slide-to="1"></li>
          <li data-target="#myCarousel" data-slide-to="2"></li>
        </ol>
        <!--wrapper for slides-->
        <div class="carousel-inner" role="listbox">
          <div class="item-active">
            <img class="first-slide" src="/img/dosa.jpg" alt="dosa" />
          </div>
          <div class="item">
            <img class="second-slide" src="/img/idli.jpg" alt="idli" />
          </div>
          <div class="item">
            <img class="third-slide" src="img/vada.jpg" alt="vada" />
          </div>
        </div>
        <!--Left and right controls-->
        <a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev">
          <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
          <span class="sr-only">Previous</span>
        </a>
        <a class="right carousel-control" href="#myCarousel" role="button" data-slide="next">
          <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
            <span class="sr-only">Next</span>
        </a>
      </div>
    </div>
  </div>

  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js" type="text/javascript"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>

  <script type="text/javascript">
    jQuery(document).ready(function () {
      $("#myCarousel").carousel({
          interval: 1200
      })
    });
  </script>
</body>
</html>

mycooking
  • jQuery(文档).ready(函数(){ $(“我的旋转木马”)。旋转木马({ 间隔时间:1200 }) });
    在HTML中更改此行:

    <div class="item-active">
    
    
    

    
    
    那个连字符不应该在那里。如果您需要一个活动的
    项目
    类,请将其添加到这两个类之后,如
    <代码>项和
    活动
    是引导程序用于运行旋转木马的类。如果第一张幻灯片上没有它们,您将出现错误

    嗯,,
    -Ted

    您确定它是
    offsetwidth
    而不是
    offsetwidth
    很抱歉,它是“offsetwidth”,我正在获取的。您可以显示代码
  • <div class="item active">