如何将光标样式设置为没有hrefs的链接的指针 [英] how to set cursor style to pointer for links without hrefs

查看:20
本文介绍了如何将光标样式设置为没有hrefs的链接的指针的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有很多 html 标签没有 href 属性来进行 onclick javascript 调用.这些链接没有指针样式的光标.他们有文字样式的光标.

I have a lot of <a> html tags without the href attribute for making onclick javascript calls. These links do not have a pointer style of cursor. They have text style cursor.

如何在不使用 href 属性的情况下将光标样式设置为链接的指针?

How can I set the cursor style to pointer for links without using the href attribute?

我知道我可以添加 href="#".我在 html 文档的很多地方都有这个,并且想知道如何在不使用 href 属性的情况下为链接制作光标样式指针.

I know I can add href="#". I have this in a lot of places in the html document, and would like to know how to make cursor style pointer for links without using the href attribute.

推荐答案

在你的 css 文件中添加这个....

in your css file add this....

a:hover {
 cursor:pointer;
}

如果您没有 css 文件,请将其添加到 HTML 页面的 HEAD 中

if you don't have a css file, add this to the HEAD of your HTML page

<style type="text/css">
 a:hover {
  cursor:pointer;
 }
</style>

您也可以通过在 javascript 末尾返回 false 来使用 href="" 属性.

also you can use the href="" attribute by returning false at the end of your javascript.

<a href="" onclick="doSomething(); return false;">a link</a>

这有很多好处.SEO 或者如果人们没有 javascript,href="" 将起作用.例如

this is good for many reasons. SEO or if people don't have javascript, the href="" will work. e.g.

<a href="nojavascriptpage.html" onclick="doSomething(); return false;">a link</a>

@see http://www.alistapart.com/articles/behavioralseparation

值得注意的是@BalusC 的answer,他提到 :hover 是对于 OP 的用例来说不是必需的.尽管可以使用 :hover 选择器添加其他样式.

Worth noting @BalusC's answer where he mentions :hover is not necessary for the OP's use case. Although other style can be add with the :hover selector.

这篇关于如何将光标样式设置为没有hrefs的链接的指针的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆