简体   繁体   中英

jquery .html shows html tags instead of applying html tags on the text

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?

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM