$(“< div />”).text(value).html不是函数错误 [英] $("<div/>").text(value).html is not a function error

查看:191
本文介绍了$(“< div />”).text(value).html不是函数错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在获得 $(< div />)。文本(值).html不是以下代码中的函数错误: p>

I am getting an $("<div/>").text(value).html 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></div>'
    );

    return true;
}

如何解决这个错误?

推荐答案

IM不确定你想要的wat,但肯定错误在这一行

IM not sure wat you want but definitely the error is in this line

 return $('<div/>').text(value).html(); 

如果要将该imagevalue包装在div中,只需使用|

If you want to wrap that imagevalue in a div, simply use|

function htmlEncode(value) { 
    return '<div><img src="'+value+'"/></div>'; //wrapping  it as an image most probably you want this
}

这篇关于$(“&lt; div /&gt;”).text(value).html不是函数错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆