[英]removeAttr to get rid of title not working in IE
我正在尝试从链接中删除title属性并将其重新用于工具提示,这里是代码片段,它给我带来了麻烦:
$('.location').each(function() {
var $this = $(this);
$this
.data('title', $this.attr('title'))
.removeAttr('title');
});
$('.location').hover(function(e) {
//hover over code
//grabs what's inside the title attribute in the html
var titleText = $(this).data('title');
//saves the tooltip text using the data method, so that the orignal tooltip text does not conflict
$(this)
.data('tipText', titleText)
.removeAttr('title');
我在这里搜索了以下代码:
$('.location').each(function() {
var $this = $(this);
$this
.data('title', $this.attr('title'))
.removeAttr('title');
});
而且效果很好,但只有一次,如果我回到IE8中的链接,原始工具提示会重新出现。 对此有何解决方案? 谢谢!
您是否能够更改
标题 ATTR比其他
标题的东西?
我相信
标题是一个保留字,可能会导致一些问题。
非工作
:(使用下面的代码更新,现在可以使用)
<a href="#" title="foo" class="location">Test Link</a>
$('.location').each(function() {
var $this = $(this);
$this
.data('title', $this.attr('title'))
.removeAttr('title');
});
工作:
<a href="#" linkTitle="foo" class="location">Test Link</a>
$('.location').each(function() {
var $this = $(this);
$this
.data('title', $this.attr('linkTitle'))
.removeAttr('linkTitle');
});
更新:
实际上,仔细观察它,你可以使用标题,但在这个特定的例子中,最好在$ .data()之外访问它。 也许是这样的:
var $this = $(this);
var t = $this.attr('title');
$this
.data('title', t)
.removeAttr('title');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.