Is it possible to use jQuery to read meta tags

Viewed 133954

Is it possible to use jQuery to read meta tags. If so do you know what the basic structure of the code will be, or have links to any tutorials.

6 Answers

Just use something like:

var author = $('meta[name=author]').attr('content');

or this as well

var author = $('meta[name=author]').prop('content');
$("meta")

Should give you back an array of elements whose tag name is META and then you can iterate over the collection to pick out whatever attributes of the elements you are interested in.

Related