Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery 1.6.2 Upgrade causing problem with meta selector

This worked fine with 1.4.

var ogimagetag = $('meta[property=og:image]').attr('content');

gives me

Uncaught Syntax error, unrecognized expression: [property=og:image]

The error seems to be sizzle.

Sizzle.error = function( msg ) {
    throw "Syntax error, unrecognized expression: " + msg;
};
jquery-1.6.2.js:4057 Uncaught Syntax error, unrecognized expression: [property=og:image]

Anyone know how I can select the content of og:image meta without causing an error? Or is this a bug with sizzle?

like image 392
jhanifen Avatar asked Oct 19 '25 15:10

jhanifen


1 Answers

Put the value in quotes. I think it's the : that's confusing sizzle. Quoting the value fixes this.

var ogimagetag = $('meta[property="og:image"]').attr('content');

Example: http://jsfiddle.net/n7zse/

like image 196
Rocket Hazmat Avatar answered Oct 21 '25 04:10

Rocket Hazmat



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!