被维基词典 API 中解析 JSON 的 jquery.find() 方法难住了
Stumped by jquery.find() method for parsing JSON from Wiktionary API
我使用 this code 作为起点来解析通过 Wiktionary API 返回的 JSON。我想自定义此代码以仅提取任何单词的 IPA 发音信息。我希望自己全部编写但无处可去,所以我开始弄乱上面链接的代码。我几乎了解所有内容,但我遇到困难的地方是:
$("#wikiInfo").find('a:not(.references a):not(.extiw):not([href^="#"])').attr('href',
function() {
return baseURL + $(this).attr("href");
}
);
我理解 .find()
方法,但是 :not()
选择器链和似乎是复合选择器的东西 a:not(.references a)
使用 class [=25] 过滤所有链接=] 内部链接?嗯?
连续的 :not()
选择器是否应用了额外的过滤器?我完全迷路了。有人可以解释上面粘贴的代码中发生了什么吗?
选择器说找到所有不在里面的andchors 'a' 和元素 class '.references' 并且没有 class extiw
和以 #
开头的属性 href
:
'a:not(.references a):not(.extiw):not([href^="#"])'
a: Select all the Anchors.
:not(.references a) : Except the ones inside elements with class references
.
:not(.extiw) : And who hasn't a class extiw
.
:not([href^="#"]) : Without an attribute href
that start with #
.
希望对您有所帮助。
我使用 this code 作为起点来解析通过 Wiktionary API 返回的 JSON。我想自定义此代码以仅提取任何单词的 IPA 发音信息。我希望自己全部编写但无处可去,所以我开始弄乱上面链接的代码。我几乎了解所有内容,但我遇到困难的地方是:
$("#wikiInfo").find('a:not(.references a):not(.extiw):not([href^="#"])').attr('href',
function() {
return baseURL + $(this).attr("href");
}
);
我理解 .find()
方法,但是 :not()
选择器链和似乎是复合选择器的东西 a:not(.references a)
使用 class [=25] 过滤所有链接=] 内部链接?嗯?
连续的 :not()
选择器是否应用了额外的过滤器?我完全迷路了。有人可以解释上面粘贴的代码中发生了什么吗?
选择器说找到所有不在里面的andchors 'a' 和元素 class '.references' 并且没有 class extiw
和以 #
开头的属性 href
:
'a:not(.references a):not(.extiw):not([href^="#"])'
a: Select all the Anchors.
:not(.references a) : Except the ones inside elements with class
references
.:not(.extiw) : And who hasn't a class
extiw
.:not([href^="#"]) : Without an attribute
href
that start with#
.
希望对您有所帮助。