jQuery   发布时间:2022-03-30  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了jquery – 获取未定义引导程序的’无法读取属性’offsetwidth’大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
尽管添加了活动类,并且在我的js函数之上定义了我的 jquery,我仍然获得了offsetwidth undefined.我必须使用旋转木马来完成我的工作,我尝试了一个模拟练习.我的第一个活动图像正在显示,然后在我单击下一步后,我在控制台中出现此错误并且图像没有滑动.

<!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>

解决方法

在HTML中更改此行:

<div class="item-active">

<div class="item active">

连字符不应该存在.如果您需要一个项目活动类,请在这两个之后添加它,例如< div class =“item active item-active”>. item和active是bootstrap用来运行轮播的类.没有他们在第一张幻灯片上,你会得到那个错误.

HTH,-Ted

大佬总结

以上是大佬教程为你收集整理的jquery – 获取未定义引导程序的’无法读取属性’offsetwidth’全部内容,希望文章能够帮你解决jquery – 获取未定义引导程序的’无法读取属性’offsetwidth’所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。