title: Jquery adding id to a span
body: <p>I am working on asp.net mvc website where we have validation messages generated inside span dynamically on button click. I am trying to assign id to span and failed doing that.</p>
  
  <p>What I tried is </p>
  
  <pre><code>Before button click
  
  &lt;span class="field-validation-error" id="prjTitle" data-valmsg-for="Title" data-valmsg-replace="true"&gt;
  
  &lt;/span&gt;
  
  after button click
  &lt;span class="field-validation-error" id="prjTitle" data-valmsg-for="Title" data-valmsg-replace="true"&gt;
  
  &lt;span for="Title"&gt;Enter Project Title&lt;/span&gt;
  
  &lt;/span&gt;
  
  
  Jquery code:
   $('#btnSubmit').click(function () {
          // Adding ids to Validation Messages 
          $('#prjTitle span').attr('id', 'prjTitle1');
  });
  </code></pre>
  
  <p>Could some one suggest me on how to add id to dynamically generated span </p>