title: Change div id within a div using jQuery
body: <p>I was able to successfully clone and remove certain part of my form thanks to <a href="https://daveismyname.blog/duplicate-form-sections-with-jquery" rel="nofollow noreferrer">David Carr - Duplicate form sections with jQuery</a></p>
  
  <p>Now I have been trying to change two <code>div</code> ids (<code>#ifYes</code> &amp; <code>#ifNo</code>) which are <code>hidden</code> to provide them with a unique id every time the form is cloned, I have added two line of coding to change the div ids which doesn't really work.</p>
  
  <p>My code is as follows:</p>
  
  <p><strong>HTML</strong>:</p>
  
  <pre><code>&lt;div id="content"&gt;
    &lt;button type="button" id="cross" class="buttonImgTop cross"&gt;&lt;/button&gt;
     &lt;div id="ValuWrapper"&gt;
        &lt;div id="ifYes"&gt; .. &lt;/div&gt;
        &lt;div id="ifNo"&gt;  .. &lt;/div&gt;
     &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;button type="button" class="buttonImg" id="repeat"&gt;&lt;/button&gt;
  </code></pre>
  
  <p><strong>JavaScript</strong>:</p>
  
  <pre><code>//define template
  var template = $('#content:first').clone();
  
  
  //define counter
  var count = 0;
  
  //add new section
  $('body').on('click', '#repeat', function() {
  
  //increment
  count++;
  
  //remove cross button div
  template.clone().find('cross').removeAttr("#cross");
  
  //update id of ifYes &amp; ifNo
  template.clone().find('#ifYes').attr("id", "#ifYes"+count);
  template.clone().find('#ifNo').attr("id", "#ifNo"+count);
  
  //loop through each input
  var inputSection = template.clone().find(':input').each(function(){
  
      //set id to store the updated section number
      var newId = this.id + count;
  
      //update id
      this.id = newId;
  
  }).end()
  
  //inject new section with animation
  .appendTo('#content').hide()
  .appendTo('#content').slideDown(500)
  return false;
  });
  
  //remove section
  $('#content').on('click', '.cross', function() {
  //slide up section
  $(this).parent().slideUp(500, function(){
      //remove parent element (main section)
      $(this).parent().child().empty();
      return false;
  });
  return false;
  });
  </code></pre>
  
  <p>Appreciate your assistance.</p>