Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

&reg becomes ® in jQuery [duplicate]

I have a jQuery code where I am trying to append to an existing div a label tag which contains a URL. Below is the code:

var strURL = 'http://financials.morningstar.com/ratios/r.htmlt=tup&region=usa&culture=en-US';
var str = '<li>';
str += '<label style="font-family:Arial;">' + strURL + '</label>';
str += '</li>';
$('#existingDiv').append(str);

When the page is actually displayed it shows the URL as:

http://financials.morningstar.com/ratios/r.html?t=tup®ion=usa&culture=en-US

like image 649
desiguy Avatar asked Dec 22 '16 14:12

desiguy


1 Answers

A quick fix would be to add the label as a text as a second step after appending the html to the existingDiv - see demo below:

var strURL = 'http://financials.morningstar.com/ratios/r.htmlt=tup&region=usa&culture=en-US';
var str = '<li>';
str += '<label style="font-family:Arial;">' + '</label>';
str += '</li>';
$('#existingDiv').append(str);
$('#existingDiv label').text(strURL);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="existingDiv"></div>
like image 119
kukkuz Avatar answered Oct 12 '22 23:10

kukkuz