How to fix this error which is stating something is not a function?
<p>I am trying to append this: <code>'&lt;div&gt;' + htmlEncode(imagefilename) + '&lt;/div&gt;'</code> when the user clicks on the cancel button (.imageCancel). But it is giving me this error: <code>$('&lt;div/&gt;').text(value).html();</code> is not a function. How can this error be fixed? Is it because        </p>

<pre><code>$('.cancelImage').eq(window.lastUploadImageIndex).append('&lt;div&gt;' + htmlEncode(imagefilename) + '&lt;/div&gt;'); 
</code></pre>

<p>is in the <code>$(".imageCancel").on("click", function(event) {</code> function?</p>

<pre><code>function htmlEncode(value) {
    return $('&lt;div/&gt;').text(value).html();
}


function startImageUpload(imageuploadform, imagefilename) {


    $(".imageCancel").on("click", function (event) {

        $('.cancelImage').eq(window.lastUploadImageIndex).append('&lt;div&gt;' + htmlEncode(imagefilename) + '&lt;/div&gt;');

        var image_file_name = $(this).attr('image_file_name');
        jQuery.ajax("deleteimage.php?imagefilename=" + image_file_name)

        $(this).parent().remove();

        $('.upload_target').get(0).contentwindow

        return stopImageUpload();

    });

    return true;
}
</code></pre>
