1.jquery给img动态添加alt属性

$(document).ready(function(){
      $("body img").each(function(){
        $(this).attr('alt','11111');
      });
});

2.动态添加keywords、description关键字

$("meta[http-equiv='X-UA-Compatible']").after(
     `<meta name="keywords" content="${keywords}">
      <meta name="description" content="${description}">`
);

3.动态添加页面title

document.title = 'title';

4.动态添加页面title后会卡顿一下闪烁默认title内容,然后才显示我们设置的内容,解决方式可以在html内容之前添加script标签设置title为空,如下:

<script>
       document.title = '\u200E';
</script>

瑞瑞_
73 声望9 粉丝