Reputation: 93
I have a string that coming from a database something like this test (test<sup>®</sup>)
that I would like to display in a label. I try to parse the text but it displays just the last value in the string. I did try to set the innerHTML
value to the string and that didn't display any value.
Is there any other way to fix this?
strHTML = $.parseHTML('test (test<sup>®</sup>)');
var Name = "";
$.each(strHTML, function (i, el) {
Name = el.wholeText;
});
$(".lbl-drug").text(Name);
Upvotes: 0
Views: 89
Reputation: 4885
strHTML = $.parseHTML('test (test<sup>®</sup>)');
$(".lbl-drug").html(strHTML);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<label class="lbl-drug"></label>
Upvotes: 2