提问人:Giacomo1968 提问时间:11/9/2023 最后编辑:Giacomo1968 更新时间:11/11/2023 访问量:27
为什么我在使用“:first:is”时收到“Uncaught Error: Syntax error, unrecognized expression: unsupported pseudo: is”
Why am I getting “Uncaught Error: Syntax error, unrecognized expression: unsupported pseudo: is” when using “:first:is”
问:
我正在尝试使用 jQuery 3.7.1 选择一个空的表单日期元素(第一个元素),但我经常使用此命令和使用此 CSS 选择器出现错误。错误是这样的:
未捕获的错误:语法错误,无法识别的表达式:不支持的伪:是
jQuery命令和CSS选择器是这样的:
$('#the_form').find("input[type='date'][name='the_date[]']:first:is(input[value=''])");
我正在macOS Sonoma(14.1.1;23B81)上使用Firefox 119.0.1(64位)进行测试和开发。为什么我收到这个“不支持的伪:是”错误?
答:
0赞
Giacomo1968
11/9/2023
#1
使用代替 .:first-of-type:is
:first:is
我不知道为什么会出现初始错误,但是当我使用而不是::first-of-type:is
:first:is
$('#the_form').find("input[type='date'][name='the_date[]']:first-of-type:is(input[value=''])");
似乎问题出在Sizzle CSS选择器引擎上。该问题记录在这里,显然将在 jQuery 4.0 中得到解决?谁知道呢!目前,适用于我的使用。:is
:first-of-type
:is
希望这也能帮助其他人!
评论