title: JQuery, how to get attribute in loop from parent
body: <p>I had a problem with array and loop, i want to set two attributes(yt to task and href to b b_yt) from array, for example:</p>
  
  <pre><code>                              //from
  &lt;div class="task" yt=""&gt;
      &lt;div class="button"&gt;
           &lt;a class="b b_yt" href=""&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;div class="task" yt=""&gt;
      &lt;div class="button"&gt;
           &lt;a class="b b_yt" href=""&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;div class="task" yt=""&gt;
      &lt;div class="button"&gt;
           &lt;a class="b b_yt" href=""&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  
                                //to
  &lt;div class="task" yt="a"&gt;
      &lt;div class="button"&gt;
           &lt;a class="b b_yt" href="a"&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;div class="task" yt="b"&gt;
      &lt;div class="button"&gt;
           &lt;a class="b b_yt" href="b"&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;div class="task" yt="b"&gt;
      &lt;div class="button"&gt;
           &lt;a class="b b_yt" href="b"&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>My js:</p>
  
  <pre><code>        var arr = ['a','b','c'];
  
          var allBtn = document.querySelectorAll('a.but.b_yt');
          var allDiv = document.querySelectorAll('div.task');
  
          allDiv.forEach(function(item, i){
              item.setAttribute('yt', arr[i]);
          });  
          //This is changing yt attribute in task and it is working
  </code></pre>
  
  <p>How to get yt attribute value from div.task and set it in href at a.but b_yt, of course in loop?</p>