Update the content attribute of the meta tag

2019-04-30 19:31发布

I have this:

<meta name="description" content="NEED_TO_UPDATE_THIS" />
<meta name="keywords" content="" />

and i need to update the content of meta tag that has the name="description" using jQuery. How can i use the selectors to choose that content atribute of that tag?

thanks

2条回答
Lonely孤独者°
2楼-- · 2019-04-30 20:03
$('meta[name=description]').attr('content', 'new value');

Although doing this doesn't make much sense because web crawlers which use this tag usually don't support javascript.

查看更多
爷的心禁止访问
3楼-- · 2019-04-30 20:18

This will make sense when you are using phantom js and prerender the js pages for seo and proxy the bots to the pre-rendered pages instead to the live site.

查看更多
登录 后发表回答