Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7942389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:57:23+00:00 2026-06-03T23:57:23+00:00

I am getting an $(<div/>).text(value).html is not a function is not a function error

  • 0

I am getting an $("<div/>").text(value).html is not a function is not a function error in the code below:

function htmlEncode(value) { 
    return $('<div/>').text(value).html(); 
}

function startImageUpload(imageuploadform, imagefilename){

    $('.imagef1_cancel').eq(window.lastUploadImageIndex).html(
        '<div>' + 
        htmlEncode(imagefilename) + 
        '<button type="button" class="imageCancel" cancel_image_file_name="' + 
        imagefilename + 
        '">CANCEL</button><br/><hr/></div>'
    );

    $('.imagef1_cancel').eq(window.lastUploadImageIndex)
        .find(".imageCancel")
        .on("click", function(event) {
            var cancel_image_file_name = $(this).attr('cancel_image_file_name');
            console.log(cancel_image_file_name) 
            jQuery.ajax("cancelimage.php?imagefilename=" + cancel_image_file_name)
            return stopImageUpload(2, cancel_image_file_name);
    });       
    return true;
}

But what I don’t get iis that it works in with the code below which is very similar.

function htmlEncode(value) { 
    return $('<div/>').text(value).html(); 
}

function stopImageUpload(success, imagefilename) {
    imagecounter++;
    $('.listImage').eq(window.lastUploadImageIndex).append(
        '<div>' + 
        htmlEncode(imagefilename) +
        '<button type="button" class="deletefileimage" image_file_name="' +
        imagefilename + 
        '">Remove</button><br/><hr/></div>'
    ); 

    var _imagecounter = imagecounter;

    $('.listImage').eq(window.lastUploadImageIndex)
        .find(".deletefileimage")
        .on("click", function(event) {

            var image_file_name = $(this).attr('image_file_name');

            jQuery.ajax("deleteimage.php?imagefilename=" + image_file_name)
                .done(function(data) {
                    $(".imagemsg" + _imagecounter).html(data);
                }
            );
            $(this).parent().remove();
        }
    );    
    return true;   
}

Why is this and how can the error be fixed?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T23:57:25+00:00Added an answer on June 3, 2026 at 11:57 pm

    I’m guessing, from that error, that you are at some point passing in a jQuery object into your method htmlEncode().

    When you use the text method of jquery, it needs to be text or something that can be interpreted as text. (for instance a string of HTML would be input and interpreted as just a normal string)

    take a look at this jsFiddle

    or just put this into your console :

    $('<div/>').text($('<div/>')).html()
    

    I think your error actually comes from where you are calling “startImageUpload” and what you are passing into it. I would have to see the rest of your code to be sure.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am getting an $(<div/>).text(value).html is not a function error in the code below:
I am getting an $(<div/>).text(value).html is not a function error in the code below:
Using this code var html='<div class=somediv></div>'; var target=document.getElementById('contentArea'); target.appendChild(html); I'm getting Uncaught Error: NOT_FOUND_ERR:
I have following html: <div class=rows> <div class=row><input type=text onchange=javascript:getIndex(this); value= /></div> <div class=row><input
I'm not sure why I'm getting this error: connection is not defined document.getElementById(flashTest).sendValFromHtml(connection.value); This
Getting an error when i use the following script to show a div when
I'm using Rails 3.2.2 and am not getting the field_with_errors div when the validation
Getting the above error in following code. How to rectify it. Thanks. Please look
I have a code like this <script type=text/javascript> function email(){ var myTextField = document.getElementById('email_hidden').value;
I'm trying to troubleshoot this code and I'm getting this error and I do

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.