【问题标题】:Getting live value of elements title - jquery?获取元素标题的实时值 - jquery?
【发布时间】:2012-01-07 19:45:31
【问题描述】:

我设置了一个工具提示,可以像这样向用户显示漂亮的标题标签...

$('.toolTips').live('mouseover', function() {
    this.tip = this.title;
    $('body').after('<div class="toolTip">' + this.tip + '</div>');
    $('.toolTip').hide().fadeIn();
    this.title = '';
});
$('.toolTips').live('mouseout', function() {
    $('.toolTip').remove();
    this.title = this.tip;
});
$('.toolTips').click(function() {
    $('.toolTip').fadeOut();
});

唯一的问题是我有时必须更改元素标题的值,例如,

$(this).attr('title', 'Why won\'t you work!');

但是我的 toolTip 功能仍然显示原始的 html 标题而不是 jquery 分配的新标题?

有什么想法吗?!

谢谢

【问题讨论】:

  • 请创建一个jsFiddle 来说明我们要解决的问题。

标签: jquery live title


【解决方案1】:

使用 .prop 代替 .attr jQuery .prop()

【讨论】:

    猜你喜欢
    • 2011-03-06
    • 2013-10-12
    • 1970-01-01
    • 1970-01-01
    • 2021-11-27
    • 2023-03-30
    • 1970-01-01
    • 1970-01-01
    • 2017-03-09
    相关资源
    最近更新 更多