如何输入 内的链接那是在 中吗?
这是我的代码
<a href="http://linkurl" class="link" title="sometitle">
text link
<span class="hidden-tooltip-data" style="display: none;"> <a
href="http://www.google.ca"> my link here destroy everything </a
</span>
</a>
,我在这里使用 Poshy 脚本
$('.link').each(function() {
var tooltip = $(".hidden-tooltip-data",this).html();
$(this).attr("title","");
$(this).poshytip({
content: function(updateCallback) {
return tooltip;
}
});
});
Here my code
<a href="http://linkurl" class="link" title="sometitle">
text link
<span class="hidden-tooltip-data" style="display: none;"> <a
href="http://www.google.ca"> my link here destroy everything </a
</span>
</a>
I use Poshy here script
$('.link').each(function() {
var tooltip = $(".hidden-tooltip-data",this).html();
$(this).attr("title","");
$(this).poshytip({
content: function(updateCallback) {
return tooltip;
}
});
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
嵌套链接非法。 中明确提到了这种情况HTML 4.01 规范。
Nested links are illegal. This case is explicitly mentioned in the HTML 4.01 Specification.
首先你不应该这样做。原因在于子
a
被完全忽略,因为它位于父a
之下。我建议您只创建一个
span
,其中包含两个不同的a
标记,其中包含所需数量的span
。First of all you shouldn't be doing that. The reason resides in the fact that the child
a
is completely ignored because it's under the parenta
.I suggest you just making a
span
that contains two differenta
tags that contain as manyspan
as required.您不应将一个链接放在另一个链接内。
You should not put a link inside another link.
默认情况下,Poshytip 将读取元素的
title
属性并将其用作工具提示内容。但是,您希望在提示中包含一个链接,如果 JavaScript 关闭(并且无法访问),则将 HTML 放入title
中会显得很丑。最好的方法是为下层浏览器包含纯文本
title
,并在data
属性中包含增强的提示内容(显然是转义标记):
在这样的属性中包含标记显然会有点混乱,因此如果您的提示具有通用格式,那么最好将 URL 包含为
data
属性并在脚本中构建标记。By default, Poshytip will read an element's
title
attribute and use that as the tooltip content. However, you want to include a link in the tip, and putting HTML in thetitle
would look ugly if JavaScript is turned off (and be inaccessible).Your best approach would be to include a text-only
title
for downlevel browsers and include the enhanced tip content in adata
attribute (obvously escaping markup):Including markup in an attribute like that obviously gets a little messy, so if your tips have a common format, it might be a better idea to include the URL as the
data
attribute and build the markup in script.