是否可以隐藏href标题?
<a href="link.html" title="Titletext">
...是代码。
由于 slimbox,我需要使用 title
属性,但我想要隐藏将鼠标悬停在链接上时显示的标题文本。
有什么想法吗?
<a href="link.html" title="Titletext">
...is the code.
I need to use the title
attribute because of slimbox, but I want to hide the title-text that shows up when hovering the mouse over the link.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(16)
一个简单的怎么样:(
更好的是,在嵌套标题中添加一些实际有用的内容。)
How about a nice simple:
(Better, put something actually useful in the nested title.)
假设您在 a 标签中使用图像标签,则可以为图像使用替代标题(甚至是空格),当您将鼠标悬停在链接上时,该标题将覆盖链接的标题。
Supposing you are using an image tag in the a tag, you can just use an alternative title for the image (even a space) and that will overwrite the title of the link when you hover over it.
使用 jQuery 这真的很容易,
它将从 li 类菜单项的任何 a 元素中删除标题 - 当然,您可以很喜欢,所以它们只需将鼠标悬停在上面即可隐藏:)
This is really easy with jQuery
That will remove the title from any a elements of the li class menu-item - of course you can get fancy so they just hide on a mouse over :)
关于我在几个网站上看到的“一个简单的好主意怎么样”的建议,我个人不会建议这样做,原因有两个。
屏幕阅读器和视障用户依赖大声朗读的标题属性。我相信这是它们在锚标签中的最初目的和原因,也是美国政府 Web 可访问性第 508 节的一个重要方面。我认为在这种情况下,屏幕阅读器会阅读所有标题;第一个,然后是第二个,这可能会让视障用户感到非常困惑。他们不明白为什么他们会听到两个特别是如果它包含不同的文本。他们听到的是两个不同的主播吗?如果是这样,为什么他们不能单击或选择他们听到的另一个并继续只获得一个网页(作为一种场景)。
如果您在两个标题的 Google 和许多其他搜索引擎中都放置其他文本,则可能会将此操作视为黑帽 seo,并可能导致您的网站被该搜索引擎列表禁止(又称填充),这种情况发生在德国的宝马身上谷歌已经。
我个人认为最好的方法是保留 title 属性,因为它应该起作用,然后使用 Javascript 或 css 以某种方式隐藏它。这些方法对屏幕阅读器、网络爬虫和视障用户没有影响。
In Regards to the "how about a nice simple" suggestion I've seen listed on several sites, I personally would not suggest this for two reasons.
Screen readers and visually impaired users rely on title attributes which are read out loud. I believe this was the initial purpose and reason for them in anchor tags and is a large aspect of USA Gov. Web Accessibility Section 508. I think a screen reader in this instance would read through all the titles; the first one and then the second one which could be very confusing for the visually impaired user. They would not understand why they are hearing two esp if it holds different text. Is it two different anchors they are hearing about? If so, why can they not click or select the other one they hear and keep getting only one web page (as a scenario).
If you place additional text in both title's Google and many other search engines may view this action as black hat seo and could lead your site to getting banned from that search engines listing (aka stuffing), this happened to BMW in Germany by Google already.
I personally would think the best method is to keep the title attribute as it was meant to function and then use Javascript or css to somehow hide it. These methods would have no impact on screen readers, web crawlers, and visually impaired users.
我喜欢 jquery...;) 我需要这个来制作作品集:灯箱的标题标签,但鼠标悬停时没有标题标签。这对我有用,感谢您的提示!
I got fancy with jquery... ;) I needed this for a portfolio: title-tags for a lightbox but none on mouse-over. This worked for me, thanks for the hint!
引用 Aron Rotteveel 在我的评论中链接到问题的第一个骗子的回答(禁用链接和 上的浏览器工具提示)
To quote Aron Rotteveel's answer from the first dupe linked in my comment to the question (Disabling browser tooltips on links and <abbr>s)
您不必将
title
属性与 Slimbox 一起使用。请参阅本页顶部附近的多个图像示例:http://code.google。 com/p/slimbox/wiki/MooToolsAPI。您只需从锚点中删除
title
属性,然后将title
文本(图像的描述)传递给 Slimboxopen
函数即可将使用锚点的onclick
事件进行调用。You don't have to use the
title
attribute with Slimbox. See the Multiple Images example near the top of this page: http://code.google.com/p/slimbox/wiki/MooToolsAPI.You can simply remove the
title
attribute from your anchor, and pass thetitle
text (your image's description) to the Slimboxopen
function, which you would call using theonclick
event of your anchor.最简单的方法是:
使用 slimbox 后,在其下方添加以下代码:
希望它能有所帮助..
the easiest way would be :
after using your slimbox, add the following code below it:
hope it can help..
不能保证,但根据 Slimbox 的工作方式,您也许可以包含标题,然后使用 jQuery 等在页面加载几秒钟后将其删除。假设 Slimbox 索引了 Title 属性并在读入后将其存储在某个位置,那么您可以在发生这种情况后安全地删除它。
No guarantees but depending on how Slimbox works you may be able to include the title then use something like jQuery to remove it a few seconds after page load. Assuming Slimbox indexes the Title attribute and stores it somewhere after reading it in, you may be able to safely remove it after this happens.
用空的 jQuery 工具提示覆盖/覆盖它?
Override/overlay it with an empty jQuery tooltip?
如果您使用jquery,您可以执行以下操作
(但尚未测试)
if you are using jquery, you could do following
(haven't tested it though)
难道你不能循环遍历 DOM 中的链接并将 title 属性设置为空字符串吗?
Couldn't you just loop through the links in the DOM and set the title attribute to an empty string.
jQuery 解决方案 - 这应该是简单的:
jQuery solution - this should be straight forward:
利用 David Thomas 的想法,您可以使用 jQuery 创建更优雅的解决方案:
Using the idea from David Thomas, you can create a more elegant solution using jQuery:
这是我的 jQuery 解决方案,它可以完成您需要的一切,并保持 title 属性的正确用法。只需根据您的需要更改选择器即可。
This is my jQuery solution, it does everything you need and keep the correct usage of the title attribute. Simply change the selector according to your needs.
正如在另一个问题上所读到的那样,我建议将“标题”属性切换为某些“数据标题”,以便残疾用户的屏幕阅读器可以使用它。正如洛金所说,保持网站对受损和残疾用户的可用性也应该是开发时需要关注的问题。
As read on another question, I suggest to switch the "title" attribute to some "data-title" in order to keep it available for screen readers for disabled users. As Lokin said, maintaining the usability of the site to impaired and disabled users should be also something to concern about when developing.