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

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

问题描述

我有很多< a> html标签,没有 href c> 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文件,请将其添加到HEAD您的HTML网页

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 =属性。 / p>

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天全站免登陆