Memoc Memoc - 1 year ago 57
HTML Question

How to set <a> tag in <kbd> by javascript?

I have a gsp with html code as below

<div class="custom-indicators-row-one">
<div class="indicator-1 pull-left" >

How can I use javascript to set
so I can define a url in it?

I had done it like this in javascript


is referring to
, 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.

Answer Source

You can use this to set <a> tag inside <kbd>

var kbd = document.getElementsByTagName('kbd')[0];
kbd.innerHTML = '<a href="" target="_blank">Click me</a>';

JSFiddle :

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download