Search code examples
jquerylivetitle

Getting live value of elements title - jquery?


I have a toolTip set up to display nice title tags to the user like so...

$('.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();
});

Only problem is I sometimes have to change the value of an elements title like,

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

But my toolTip feature still displays the original html title and not the new title assigned by jquery?

Any ideas?!

Thanks


Solution

  • Use .prop instead of .attr jQuery .prop()