title: $("<div/>").text(value).html is not a function error
body: <p>I am getting an <code>$("&lt;div/&gt;").text(value).html is not a function</code> error in the code below:</p>
  
  <pre><code>function htmlEncode(value) { 
      return $('&lt;div/&gt;').text(value).html(); 
  }
  
  function startImageUpload(imageuploadform, imagefilename){
  
      $('.imagef1_cancel').eq(window.lastUploadImageIndex).html(
          '&lt;div&gt;' + 
          htmlEncode(imagefilename) + 
          '&lt;button type="button" class="imageCancel" cancel_image_file_name="' + 
          imagefilename + 
          '"&gt;CANCEL&lt;/button&gt;&lt;/div&gt;'
      );
  
      return true;
  }
  </code></pre>
  
  <p>How can this error be fixed?</p>