In the page <head> I have <script>, <style>, <link> and <meta> tags. I just want to read meta information from the head and nothing else. I’m mainly interested in <meta name="description"..> and <meta name="keywords"...>.
I want the full meta tag and not its content. I know I can read content by doing
$('head meta[name=descritption]').attr('content')
but that’s not what I want. I want an output like
<meta name="description" content="" >
<meta name="keywords" content="" >
What is an efficient way to do this?
jQuery has no simple way of saying “get the HTML of the currently-selected element.” Your meta tags probably have no content either, so you must want just the HTML of the meta tags. I’m not sure why you put the
[name=description]condition there as it seems to contradict what you want, but you can keep it: