Reputation: 903
How can I append link's title value as a link's text. I have this code:
<a href="#" title="Title value"></a>
...and after clicking on it I want to have something like this:
<a href="#" title="Title value">Title value</a>
Thank you!
Upvotes: 1
Views: 83
Reputation: 8583
This
$('a').click(function() {
$(this).text($(this).attr('title'));
}
should work.
Maybe you want to give your <a>
tag a special ID, so you can reference it.
Upvotes: 0
Reputation: 337560
Try this:
$("a").click(function() {
$(this).text($(this).prop("title"));
});
Upvotes: 4