Why does this return an error?
<link rel="shortcut ic开发者_C百科on" type="image/x-icon" href="gfx/favicon.ico" />
var link = $('link[rel=shortcut icon]');
error:
uncaught exception: Syntax error, unrecognized expression: [rel=shortcut icon]
You need to put the value of rel
in quotes:
var link = $('link[rel="shortcut icon"]');
See the jQuery docs on attribute selectors:
jQuery('[attribute="value"]')
attribute An attribute name.
value An attribute value. Quotes are mandatory.
精彩评论