How to add text from span tag to data-attr?
Example:
I have this code
Your You are using a callback to Demotitle="icon"
attr()
function, so return the value which you need to set inside the function using .text()
.$(document).ready(function () {
$("[title='icon']").attr('data-attr', function () {
return $(this).find('span').text();
}).removeAttr('title');
});