2

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?

2
  • Have you tried to use .text() instead? Commented Nov 14, 2013 at 10:36
  • ya... .text() strips off html tags. For e.g. if I have data.bodyText = </br> &lt;strong&gt; Test This Text ;/strong&gt; ... then it will ignore </br> tag... Commented Nov 14, 2013 at 10:45

1 Answer 1

1

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);
Sign up to request clarification or add additional context in comments.

6 Comments

instead of data.bodyText = "<strong>Test This Text;</strong>"; please check with data.bodyText = "&lt;strong&gt; Test This Text ;/strong&gt;" .... you will see the issue
ok, now i get it, u can do something like jsfiddle.net/F9Kjt/2 where u replace the text.. take a look here stackoverflow.com/questions/6784560/…
This won't cover everything...check out this jsfiddle.net/uDjES ... this should display check3 in bold...
jsfiddle.net/uDjES/1 i just add a while, maybe u'll need just to add the ';' in that indexOf and reaplaces
yup... that works as expected. Any reason why this happened? I mean this used to work right with only .html before...
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.