Reputation: 9340
We have $str = " hello";
What's the best way to get $newstr
equal to  hello
; and so on to be sure it is displayed on the page the same way using jQuery?
Upvotes: 0
Views: 182
Reputation: 80
I think both answers by Matt Schmiermund and Alex Gidan are directing you to the right place.
You should try something like this :
var a = "<div>Your HTML & More</div>";
var span = document.createElement("span");
$(span).text(a)
$(span).html()
this will return the following :
"<div>Your HTML & More</div>"
Upvotes: 3
Reputation: 2679
If you have to do it with JQuery
(directly from your JS) you can use .text()
/ .html()
functions:
$('<div/>').text(value).html();
$('<div/>').html(value).text();
Upvotes: 2