问题描述
如何显示标题
在鼠标上,我想在 div 中而不是在基本工具提示中显示它如何?
有没有办法在 JavaScript 或
jQuery
中做到这一点?
要使标题文本出现在 div 中,请执行以下操作:
HTML:
<a href='#' title='title text' class='noTitle'>link</a>
JS:
$(".noTitle").hover(function() {var thisTitle = $(this).attr("title");$(this).removeAttr("title");$("#titleText").html(thisTitle);},功能() {var replaceTitle = $("#titleText").html();$(this).attr("title",replaceTitle);$("#titleText").html("");});
还没试过,但像这样的东西应该适合你.它应该在悬停时获得标题,将其添加到 div 并删除标题属性.然后在鼠标悬停时添加带有 div 文本的 title 属性.
How i can show the title of this
<a href="www.google.com"
title="google"
onclick="search.php"
target="_blank">google</a>
on mouse on, I want show it in a div and not in the basic tooltip how?
I think its easy to show but i dont know how to hide the original browser tooltip
Is there a way to do this in JavaScript, or in
jQuery
?
解决方案
For help on hiding the title though check out this other discussion:
Hide native tooltip using jQuery
To make the title text appear in a div do this:
HTML:
<div id='titleText'></div>
<a href='#' title='title text' class='noTitle'>link</a>
JS:
$(".noTitle").hover(function() {
var thisTitle = $(this).attr("title");
$(this).removeAttr("title");
$("#titleText").html(thisTitle);
},
function() {
var replaceTitle = $("#titleText").html();
$(this).attr("title",replaceTitle);
$("#titleText").html("");
});
Haven't tried it but something like this should work for you.It should get the title on hover, add it to the div and remove title attribute. Then add back the title attribute with the div text when you hover out.
这篇关于显示<a>的标题div 中的链接而不是工具提示中的链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!