jQuery Code Snippet获取每个图像的alt标签并设置title标签,使其与alt标签相同。 可能有助于改善网页的SEO,并增加了对使用图像标题标签的浏览器(如Firefox)的支持。
jQuery(document).ready(function($) {
$("img:not([title])").each(function() {
if($(this).attr("alt") != '') $(this).parent().attr("title", $(this).attr("alt"))
else $(this).parent().attr("title", $(this).attr("src"));
});
});
From: https://www.sitepoint.com/jquery-set-image-title-alt-tag/