title: Getting 'cannot read property 'offsetwidth' of undefined bootstrap
body: <p>I get the <code>offsetwidth</code> undefined in spite of adding active class and also defining my jquery just above my js function. I have to use carousel for my work and I tried a mock one for practice. My first active image is displaying and after I click next I get this error in console and the images are not sliding.</p>
  
  <pre><code>  &lt;!DOCTYPE html&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
    &lt;meta charset="utf-8"&gt;
    &lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&gt;
    &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;
    &lt;link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css"&gt;
  
    &lt;title&gt;mycooking&lt;/title&gt;
  
  &lt;/head&gt;
  &lt;body&gt;
    &lt;!--indicatiors--&gt;
    &lt;div class="container"&gt;
      &lt;div class="row-fluid"&gt;
        &lt;div id="myCarousel" class="carousel slide" data-ride="carousel"&gt;
          &lt;ol class="carousel-indicators"&gt;
            &lt;li data-target="#myCarousel" data-slide-to="0" class="active"&gt;&lt;/li&gt;
            &lt;li data-target="#myCarousel" data-slide-to="1"&gt;&lt;/li&gt;
            &lt;li data-target="#myCarousel" data-slide-to="2"&gt;&lt;/li&gt;
          &lt;/ol&gt;
          &lt;!--wrapper for slides--&gt;
          &lt;div class="carousel-inner" role="listbox"&gt;
            &lt;div class="item-active"&gt;
              &lt;img class="first-slide" src="/img/dosa.jpg" alt="dosa" /&gt;
            &lt;/div&gt;
            &lt;div class="item"&gt;
              &lt;img class="second-slide" src="/img/idli.jpg" alt="idli" /&gt;
            &lt;/div&gt;
            &lt;div class="item"&gt;
              &lt;img class="third-slide" src="img/vada.jpg" alt="vada" /&gt;
            &lt;/div&gt;
          &lt;/div&gt;
          &lt;!--Left and right controls--&gt;
          &lt;a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev"&gt;
            &lt;span class="glyphicon glyphicon-chevron-left" aria-hidden="true"&gt;&lt;/span&gt;
            &lt;span class="sr-only"&gt;Previous&lt;/span&gt;
          &lt;/a&gt;
          &lt;a class="right carousel-control" href="#myCarousel" role="button" data-slide="next"&gt;
            &lt;span class="glyphicon glyphicon-chevron-right" aria-hidden="true"&gt;&lt;/span&gt;
              &lt;span class="sr-only"&gt;Next&lt;/span&gt;
          &lt;/a&gt;
        &lt;/div&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  
    &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js" type="text/javascript"&gt;&lt;/script&gt;
    &lt;script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"&gt;&lt;/script&gt;
  
    &lt;script type="text/javascript"&gt;
      jQuery(document).ready(function () {
        $("#myCarousel").carousel({
            interval: 1200
        })
      });
    &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>