title: jquery change div text
body: <pre><code>'&lt;div id="'+div_id+'" class="widget" style="height:60px;width:110px"&gt;\n\
              &lt;div class="widget-head ui-widget-header" style="cursor:move;height:20px;width:130px"&gt;'+
           '&lt;span id="'+span_id+'" style="float:right; cursor:pointer" class="dialog_link ui-icon ui-icon-newwin ui-icon-pencil"&gt;&lt;/span&gt;'  +
            dialog_title+'&lt;/div&gt;&lt;/div&gt;
  </code></pre>
  
  <p>I have a div constructed using the above string. After some processing..I have to change the dialog_title in the above div. I am trying to do it with the following code</p>
  
  <pre><code>$('#'+div_id+' .widget-head').text("new dialog title");
  </code></pre>
  
  <p>While this changes the dialog title..it removes the span element which is used to open a dialog box.</p>
  
  <p>I tried to the replaceWith method with a string with new dialog title..but that shows NaN for title and the span though visible cant be clicked(are events disabled?)</p>
  
  <p>How do I change the text without losing the span and ability to click it.</p>
  
  <p>Thanks in advance.</p>