JQuery selector: link not working with $ .is () or $ .filter () ...?

It seems that the selector is ":link"not supported by jQuery filter()or is(). For example, if I rate $(":link")on a page, it returns multiple links. If I rate $(":link").filter(":link")or $(":link").is(":link"), an error occurs. The error message is "Syntax error, unrecognized expression: link".

Is it for design? Do filter()and is()do not support the same CSS selector, does jQuery usually work? Is there any information about the difference?

+3
source share
1 answer

, jQuery , querySelector querySelectorAll , . , :link, , , , , , .

<a href="www.foo.com">Hello</a>

alert($("a").is("a")); // do it this way

// changes the anchor CSS, but does not return the length
alert($(":link").css('background','yellow').length); 

: http://jsfiddle.net/xWPw7/4

+4

Source: https://habr.com/ru/post/1764194/


All Articles