I encountered this question and can't figure out what is right answer for it. Help Please.
5 回答
其实没有一个是对的。他们正在寻找的答案可能是 (a),这意味着每个链接都有一个以 https开头的 HREF。但是由于它们不包含协议字符串,因此没有什么可以阻止它匹配类似https.wordpress.com
或之类的 URL https/images/kitten.gif
。
According to the jQuery documentation, it should be option a, BUT that won't help if you are already on a page loaded by https and you have relative links.
This is a question about CSS and regular expressions, though it looks like a jQuery question. The trick is that RegEx's use the ^
and $
characters to indicate the beginning and ending of a line, respectively. Therefore, the ^=
operator would match the beginning of the href
attribute of the anchor elements, and the right answer is option a.
The correct answer is
$('a[href^=https]');
according to jQuery website..
Selects elements that have the specified attribute with a value beginning exactly with a given string.
jQuery( "[attribute^='value']" )
好的,我找到了.. 是的,正确的选项是'a'....
as '^' - 将检查初始表达式 '$' - 将检查确切的单词 https