我已将HTML标记放在<a title=""></a>
标记
我的<a>
标记:
<a href="/survey/MyClicks/myclicks" class="toolLink" title="<h2>my clicks!</h2> Group your contacts to target your <span>ASK</span> to the specific people you want opinions from.">Clicks</a>
当我将鼠标悬停在此标记上时,它会将HTML标记显示为标题,但我不想在标题中显示HTML标记。
我该如何解决这个问题?
答案 0 :(得分:0)
删除title
属性。如果使用它,浏览器可以根据自己的需要将其用作工具提示,并且通常他们喜欢这样做 - 这种使用或多或少是title
属性的基本概念。
如果存在具有该属性的特定原因(例如假设对搜索引擎的影响),则可以使用removeAttribute()
方法将该属性保留在HTML中,但使用客户端JavaScript将其删除。
答案 1 :(得分:0)
您应该删除工具提示中的HTML,否则您需要一些基于HTML的提示插件,例如 Tipsy 。
Tipsy是一个jQuery插件,用于根据锚标记的标题属性创建类似Facebook的工具提示效果。
答案 2 :(得分:0)
您可以在标题中显示文字,然后您可以删除该属性。
var ttext;
$('.toolLink').hover(function(){
ttext = $(this).attr('title');
//$('.showTitle').text(ttext); //use only if you are displaying the title text
$(this).removeAttr('title');
},function(){
$(this).attr('title', ttext);
});
答案 3 :(得分:0)
我面临同样的问题,这有点棘手,但是我使用像这样的jquery来解决这个问题。你不是用jquery标记这个问题,但我认为这有助于你。
var attrTitleValue="";
$('#YourAnchorTag').hover(function() {
attrTitleValue = $('#YourAnchorTag').attr("title");//Its depend upon you how you find your anchor tag
$('#YourAnchorTag').attr("title", "");
}, function() {
$('#YourAnchorTag').attr("title", attrTitleValue);
});