Safari - 错误:语法错误,无法识别的表达式:输入[data-card-type =“payment-one

时间:2021-08-20 22:46:24

on mac Safari (and older versions of FF v.38 and older) we are receiving the following error:

在mac Safari(以及旧版本的FF v.38及更早版本)上,我们收到以下错误:

Error: Syntax error, unrecognized expression: input[data-card-type="payment-one"

错误:语法错误,无法识别的表达式:输入[data-card-type =“payment-one”

jQuery Version: https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js

jQuery版本:https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js

$(this).change(function() {
  if($(this).val() != '' ) {
    $('input[data-card-type="'+paymentGroup+'"').val('').prop('disabled',true);

In Safari's Console, in red it reads: Error: Syntax error, unrecognized expression: input[data-card-type="payment-one and beneath the error it reads: (anonymous function)

在Safari的控制台中,红色显示:错误:语法错误,无法识别的表达式:输入[data-card-type =“payment-one及其读取的错误:(匿名函数)

Does any of this look like it conflicts with jQuery 2.1.4, or maybe there is something else incorrect?

这有什么看起来与jQuery 2.1.4冲突,或者可能有其他不正确的东西?

1 个解决方案

#1


38  

This looks like it's a Safari issue, but really it never should have worked. You need to close the [data-card-type=paymentGroup statement, without that ending ] Safari will throw a fit. I know this from experience. Chrome (my main dev browser) will let this fly without a single peep, but Safari breaks (and rightfully so, its not valid).

这看起来像是一个Safari问题,但实际上它永远不应该有效。你需要关闭[data-card-type = paymentGroup语句,没有那个结束] Safari会抛出一个合适的东西。我从经验得到的这个结论。 Chrome(我的主要开发浏览器)可以让它在没有一次窥视的情况下飞行,但Safari会中断(理所当然,它无效)。

Replace your code with this:

用以下代码替换您的代码:

$(this).change(function() {
   if($(this).val() != '' ) {
     $('input[data-card-type="'+paymentGroup+'"]').val('').prop('disabled',true);

#1


38  

This looks like it's a Safari issue, but really it never should have worked. You need to close the [data-card-type=paymentGroup statement, without that ending ] Safari will throw a fit. I know this from experience. Chrome (my main dev browser) will let this fly without a single peep, but Safari breaks (and rightfully so, its not valid).

这看起来像是一个Safari问题,但实际上它永远不应该有效。你需要关闭[data-card-type = paymentGroup语句,没有那个结束] Safari会抛出一个合适的东西。我从经验得到的这个结论。 Chrome(我的主要开发浏览器)可以让它在没有一次窥视的情况下飞行,但Safari会中断(理所当然,它无效)。

Replace your code with this:

用以下代码替换您的代码:

$(this).change(function() {
   if($(this).val() != '' ) {
     $('input[data-card-type="'+paymentGroup+'"]').val('').prop('disabled',true);