title: How to find a parent element width in JavaScript or jQuery?
body: <p>I have a <strong>HTML</strong> code like this -</p>
  
  <pre><code>&lt;div class="bs-example"&gt;
      &lt;input type="text" id="typehead" style="width: 500px;" class="form-control" placeholder="accounts" /&gt;
      &lt;input type="text" class="form-control" placeholder="accounts" /&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I have to find the width of the parent element having ID <strong>typehead</strong>.</p>
  
  <p>So in this case I have to find width of the div having class <strong>bs-example</strong>.</p>
  
  <p>I can't use <strong>ID</strong> in the upper div so that I can have the width of the element by ID because <strong>I want a re-usable code because it should be used many places in the page</strong>.</p>
  
  <p>What I have done is -</p>
  
  <pre><code>function myFunction()
  {
      var x = document.getElementById("myLI").parentNode.parentElement.width;
      document.getElementById("demo").innerHTML = x;
  }
  </code></pre>
  
  <p>But it is not working.</p>