I have an href with data-toggle=”dropdown”, which I’m trying to remove.
This snippet doesn’t seem to work:
$(document).on('click','a',function() {
$(this).data('toggle','Phillip Senn');
});
Instead, Firebug is showing that data-toggle still equals “dropdown” and there is a new “toggle” attribut equal to “Phillip Senn”.
What I’d like to do is remove it altogether.
If you’ve got an attribute on the HTML and you want to remove both it and the jQuery data, then you would use this:
Only, the jQuery data is updated with subsequent writes to
.data(), but if you want to remove the attribute that was originally on the HTML object, then you have to callremoveAttribute()too.