jquery .html shows html tags instead of applying h

2019-08-02 07:04发布

My code is

 printMsg : function(data) {
    $("#message").html(data.bodyText);
    ...
    }

here

data.bodyText   =    <strong> Test This Text  ;/strong>

I am suppose to display data as Test This Text & for that I did

 $("#message").html(data.bodyText);

This displayed the text correctly with jquery previous versions (1.9)

Now with jquery 1.10 it displays

<strong> Test This Text  </Strong>

Can you please tell me reason for this? & any solution if you have?

1条回答
Luminary・发光体
2楼-- · 2019-08-02 07:45

are you trying to do something like this? in jquery 1.10.1 it seems work normally

HTML

<span id='message'></span>

JS

var data = {};
data.bodyText = "<strong>Test This Text;</strong>"; 
$("#message").html(data.bodyText);
查看更多
登录 后发表回答