Reputation: 3038
I have a string like below
var result = "Here is the memory consumption : @10.11.10.22 : <a href='https://abc.mystats.com/static/mem3412671190.11.svg'>view</a>"
I need to show a link along side the regular text.Something like this
Here is the memory consumption : @10.11.10.22 : view
I have looked into some of the javascript's methods like link()
but I am not sure how to use it in my case. I can seperate out https://abc.mystats.com/static/mem3412671190.11.svg
and hook it up to a word
something like this
var word = "view";
var res = word.link("https://abc.mystats.com/static/mem3412671190.11.svg");
But then I need to show the word view along side the regular text as shown above.How do I do it?
Note: I need to show this in a webpage where the user can see this text with the link.Currently this piece of string is what I get from the backend.
Upvotes: 0
Views: 48
Reputation: 29057
You can use the innerHTML property to set the HTML within the designated element:
const result_container = document.getElementById('result-container');
const result = 'Here is the memory consumption : @10.11.10.22 : <a href="https://abc.mystats.com/static/mem3412671190.11.svg">view</a>';
result_container.innerHTML = result;
<div id="result-container"></div>
Upvotes: 2