无法处理html控件的“title”属性

时间:2012-03-21 05:06:52

标签: html

我的HTML:

  <input id="Text2" type="text" title="nepal" name="text" />

当我跑这个时。我出去的是:
enter image description here

在实际项目中title attr包含难以更改的内容。我只想删除工具提示部分意味着不希望显示nepal来自title属性。我搜索了很多但无法处理它。任何建议。谢谢。

4 个答案:

答案 0 :(得分:2)

您不应该为自己使用内置属性。 title属性是显示该工具提示的原因。摆脱它,而是使用custom data attribute

<input id="Text2" type="text" data-imp-id="nepal" name="text" />

答案 1 :(得分:0)

删除工具提示:删除title属性,不会显示工具提示。您还可以使用rel属性。

答案 2 :(得分:0)

只要鼠标悬停在属性上,就可以通过删除属性来阻止工具提示出现。这很容易在jQuery中实现。

var titleAttribute;

$('#Text2').hover(function() {
    titleAttribute = $(this).attr("title");
    $(this).attr("title", "");
}, function() {
    $(this).attr("title", titleAttribute);
});

答案 3 :(得分:0)

我不明白如果您不需要工具提示,为什么要添加TITLE标签。

因此可以有两种解决方案: 1)删除标题标记,就像在代码中没有任何重要性一样。 2)如果你想显示一个工具提示并且不想显示尼泊尔,请在输入框的上下文中更改它,通常使用标题标签。 http://www.searchenginejournal.com/how-to-use-link-title-attribute-correctly/7687/