我有一个<a id="javascriptlink">标签,没有href.它的动作由jquery onclick处理.所以,我想放入css a:link {text-decoration: underline;}并a:hover {text-decoration: none;}使其看起来像一个链接.
但是,锚点下划线似乎仅在呈现href属性时才起作用.任何的想法?
Ani*_*han 20
a:link适用于仅存在的href.如果没有href,它只是一个锚而不是一个链接.
a {text-decoration: underline;}
Run Code Online (Sandbox Code Playgroud)
a{
text-decoration: underline;
cursor: pointer;
}
a:hover{
text-decoration: none;
}
Run Code Online (Sandbox Code Playgroud)
只需添加href属性,但通过取消事件使链接不执行任何操作。
<a href="#" onclick="event.preventDefault(); return false;" id="javascriptlink">
Run Code Online (Sandbox Code Playgroud)