title: How to loop and set inner content of DOM elements in jQuery and JavaScript?
body: <p>I'm trying to loop through <code>divs</code> and set the content of a <code>div</code> inside the outer <code>div</code>. I tried this.</p>
  
  <p>Here is the HTML <code>div</code>'s I want to loop through and I want to set the content of <code>div</code> with class <code>content-detail</code> with the value for its attribute data-form data.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>//the javascript code I used is this 
  
  $(function($) {
    for (var i of $(".item .content-detail")) {
      var container = document.querySelector($(i)[0]);
      var formData = $(i).attr("data-formdata");
    }
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.2.3/jquery.min.js"&gt;&lt;/script&gt;
  
  &lt;div class="item"&gt;
    &lt;div class="down-div"&gt; &lt;/div&gt;
    &lt;div class="detail"&gt;
      &lt;h4&gt;Detail&lt;/h4&gt;
      &lt;div id="div_" class="content-detail" data-formdata="my Item"&gt;
  
      &lt;/div&gt;
      &lt;div class="text-center"&gt;
        &lt;button class="btn btn-blue center"&gt; SET !&lt;/button&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;div class="item"&gt;
    &lt;div class="down-div"&gt; &lt;/div&gt;
    &lt;div class="detail"&gt;
      &lt;h4&gt;Detail&lt;/h4&gt;
      &lt;div id="div_" class="content-detail" data-formdata="my Item"&gt;
  
      &lt;/div&gt;
      &lt;div class="text-center"&gt;
        &lt;button class="btn btn-blue center"&gt; SET !&lt;/button&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>But am stuck at this point  <code>var container = document.querySelector($(i)[0]);</code> 
  I don't know how to get the <code>jquery</code> selector of that current div to a variable.</p>