admin管理员组文章数量:1381492
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?
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?
Share Improve this question edited Jun 11, 2012 at 5:57 munity wiki5 revs, 3 users 69%
vaibhav bindroo 0
4 Answers
Reset to default 3obj.style.textDecoration = "none"
You might want to consider replacing the anchor with a span.
This sounds like a stylesheet issue. Is there something like
a {
text-decoration: underline;
}
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 an href
attribute.
a:link,
a:visited,
a:hover,
a:active {
text-decoration: underline;
}
Use this on HTML:
<a href="mylink" style="text-decoration
本文标签: Disable Anchor tag and remove underline also in javascriptStack Overflow
版权声明:本文标题:Disable Anchor tag and remove underline also in javascript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743946109a2566434.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论