0

I got following json:

{"results":[{"id":"1","title":"Hello","content":"Hello<br>world"}]}

the data can be successfully displayed in the following way

$('<td class="a">').html(res.id),
$('<td class="b">').html(res.title),
$('<td class="c">').html(res.content),

The only problem is that I want to display <br> tag as well. Is there any function in jquery which can help me to display html tag as well?

1 Answer 1

2

Yes, you can use text:

We need to be aware that this method escapes the string provided as necessary so that it will render correctly in HTML. To do so, it calls the DOM method .createTextNode(), does not interpret the string as HTML.

$('<td class="a">').text(res.id);
$('<td class="b">').text(res.title);
$('<td class="c">').text(res.content);
Sign up to request clarification or add additional context in comments.

Comments

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.