I have a anchor tag which I would like to disable or enable depending upon some condition. I am able to achive this using the following function:
function disableEnableAnchor(obj, disable) {
if(disable) {
var href = obj.getAttribute("href");
if(href && href != "" && href != null)
obj.setAttribute('href_bak', href);
obj.removeAttribute('href');
} else {
var href_bak = obj.attributes['href_bak'].nodeValue;
obj.setAttribute('href', href_bak);
}
}
But I am not able to remove the underline when the anchor is in a disabled state. How can I achieve this inside this function?
This sounds like a stylesheet issue. Is there something like
in a CSS file that’s applied to the page?
Replacing it with the following CSS should make
<a>tags only be underlined when they have anhrefattribute.