I have a variable in javascript returned by AJAX which may contain a simple string or a href code like <a href="www.example.com">EXAMPLE</a>
. I have to detect whether it is a link or simple string and display accordingly.
i.e. if it is a link then a hyperLink is to be displayed with text as EXAMPLE or if it is a simple string then it has to be displayed as it is. I can able to do it in angular using
<span ng-bind-html-unsafe="name_of_variable">
How can I do it in javascript code with javascript variable?