Blynn
Blynn

Reputation: 1411

JQuery auto meta tag description

I'm trying to get the first class and apply the same text into a meta description, but the meta isn't loading in the var get. Can someone take a look and debug this?

Thanks!

$(document).ready(function() {
// add the class of first to any element to get the meta data to populate
var get = $('.first').html();
var myclone = $('meta[name=description]').attr("content");
$(get).appendTo(myclone);
//alert(get);
});

Upvotes: 0

Views: 196

Answers (1)

Dave
Dave

Reputation: 6179

I get what you're trying to do but I would not recommend it. You can't count on search engines to run your javascript so unless you're using the description meta info for something completely unrelated to describing your pages content for search engines, you could be trying to do something here which is a waste of effort. Your description should be coming back in your original HTML, and not rendered from javascript.

That being said, if you really want to keep doing what you're doing...

$('meta[name=description]').attr("content", $('.first').text());

Upvotes: 1

Related Questions