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®ion=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
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®ion=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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With