开发者

Get link tag returns error

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜