jQuery('img').each(function() {
jQuery(this).attr('title', jQuery(this).attr('alt'));
})
How can I modify the code above so that it only applies the title attribute from alt if it doesn't already have a title attribute? In other words, if the image already has a non-empty title attribute, this code shouldn't execute.
jQuery('img:not([title!=""][title])').each(function() { jQuery(this).attr('title', jQuery(this).attr('alt')); })
– Kailash Yadav