Changing robot meta tags with JavaScript and jQuery
<p>I have a strange problem. I have pages with sports events, the events have dates of when they are played (h1). What I'm trying to accomplish is: when the event has ended, the page will change to noindex.</p>

<p>Here is my code currently:</p>

<pre><code>if (h1 &lt; +moment().add(172800000)) {

    $('meta[name=robots]').attr('content', "noindex,follow,noodp,noydir");
    $('meta[name=googlebot]').attr('content', "noindex,follow");

    console.log("ARCHIVED");
} else {
    console.log("NOT ARCHIVED");
}
</code></pre>

<p>The h1 &lt; moments simply compares the start date to the current date + 48 hours. The console.log stuff is working fine which means the if statement works. I've seen MANY posts similar to this, and it would seem that the <code>$('meta[name=googlebot]').attr('content', "deindex,follow")</code> <em>should</em> work, but it's not.</p>

<p>Do any of you see an error in the code? Am I missing something?</p>

<p>Here are my current meta tags that I'm trying to change </p>

<pre><code>&lt;meta name="robots" content="index,follow,noodp,noydir" /&gt;
&lt;meta name="googlebot" content="index,follow" /&gt;
</code></pre>