Q:

How to set  tag in  by javascript?

I have a gsp with html code as below
<div class="custom-indicators-row-one">
    <div class="indicator-1 pull-left" >
        <kbd></kbd>
    </div>

How can I use JavaScript to set <a> inside <kbd> so I can define a url in it?
I had done it like this in JavaScript
$element.html(indic.link(url));

where $element is referring to <kbd>, indic is a value and url is to be opened when the value clicked. I noticed by this method I have the url open in new tab or can't change the color of the font.

A:

You can use this to set <a> tag inside <kbd>
var kbd = document.getElementsByTagName('kbd')[0];
kbd.innerHTML = '<a href="www.example.com" target="_blank">Click me</a>';

JSFiddle : https://jsfiddle.net/5caps8f3/

