Vinicius Santana
Vinicius Santana

Reputation: 4106

Hot to prevent .text to escape the html tags on the browser?

The following code apparently escapes the HTML tags and prints

<p>Full Membership - 1 Year:<span>$25</span></p>

on the Browser instead of

Full Membership - 1 Year:$25

$(".ms_total").text("<p>Full Membership - 1 Year:<span>$25</span></p>");   

How do I prevent that?

Upvotes: 0

Views: 228

Answers (2)

Sam1604
Sam1604

Reputation: 1489

Use .html insted of .text. Because .text displays the contents which is in quotes

DEMO

Upvotes: 1

Neel
Neel

Reputation: 11721

try .html :-

$(".ms_total").html("<p>Full Membership - 1 Year:<span>$25</span></p>");   

As documented in official site :-

Get the HTML contents of the first element in the set of matched elements or set the HTML contents of every matched element.

Upvotes: 2

Related Questions