Jquery链接了良好的实践 [英] Jquery links good practice

查看:76
本文介绍了Jquery链接了良好的实践的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有这个

<a href="#">something</a>

然后我在Jquery代码中处理它。这会在悬停时显示浏览器状态栏中的#。这是生产的好方法,还有其他选择吗?
谢谢

and then I handle it in Jquery code. This displays the # in browser status bar when hover. Is this a good practice for production, other alternatives? Thanks

推荐答案

您甚至不必定义href属性。通常我会像这样编码:

You don't even have to define the href attribute. Usually I will just code like this:

<a onclick="...">Link</a>

$('#blah').click(function(){...});
...
<a id="blah">Link</a>

检查规格:

http://www.w3.org/TR/2003/WD -xhtml2-20030506 / mod-hypertext.html

http://www.w3.org/TR/html401/struct/links.html#edef-A

还有更多我确定,但我认为这实际上取决于你正在使用的doctype。无论如何长话短说,不指定href属性并且验证器应该传递它是不错的做法。是的......地址栏中的#总是让我看起来很乱。

There are more I'm sure but I suppose it really depends on the doctype you're using. Anyway long story short it's not bad practice to not specify the href attribute and a validator should pass it. And yeah... # in the address bar always looks messy to me.

这篇关于Jquery链接了良好的实践的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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