javascript - How can I toggle the title attribute of a element? -


i have html:

<i class="fa fa-check" title="click accept"></i> <i class="fa fa-check checked" title="undo"></i> <i class="fa fa-check" title="click accept"></i> 

as see everywhere there checked class name, title of element has undo (also title of other elements have click accept). mean checked class name , undo title have unique.

now i'm toggling class name this:

$('.fa-check').on('click', function(){    $el = $(this);    $el.not($el).removeclass('checked');    $el.toggleclass('checked'); }); 

in other word, i'm removing checked class elements , toggling checked class clicked element. want know, how can same thing title attribute ?

prop preferred on attr

for example:

$('.fa-check').on('click', function(){    var $el = $(this);    var title = $(this).prop('title');     if(title === 'undo'){      // reset state      $el.removeclass('checked').prop('title', 'click accept');    } else {      // mark checked      $el.addclass('checked').prop('title', 'undo');    } }); 

Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -