Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Update the content attribute of the meta tag

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

like image 456
Pedro Luz Avatar asked Oct 22 '10 13:10

Pedro Luz


People also ask

What is content attribute in meta?

The <meta> content Attribute in HTML is used to given the values that are related to the http-equiv or name attribute. The content attribute can associated with the <meta> element. Syntax: <meta content="text"> Attribute Values: It contains single value text which is used to specify the content of the meta information.

What is the refresh meta tag used for?

HTML allows for the specification of meta information within META tags. A popular use of this technique involves specifying redirections or page reloads within HTML code, rather than relying on HTTP headers to do so (for example, HTTP status code 302 Document moved for redirections).

How do I add meta content?

If you want to add a meta tag to your website, search for instructions about modifying the <head> of your page on your CMS (for example, search for "wix add meta tags"). Use this tag to provide a short description of the page. In some situations, this description is used in the snippet shown in search results.


2 Answers

$('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.

like image 61
Darin Dimitrov Avatar answered Oct 23 '22 07:10

Darin Dimitrov


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.

like image 29
Ravi D Avatar answered Oct 23 '22 08:10

Ravi D