gpt4 book ai didi

jquery - 未捕获语法错误,无法识别的表达式 : (spaces and slashes in query)

转载 作者:行者123 更新时间:2023-12-01 06:37:01 24 4
gpt4 key购买 nike

我正在尝试查询具有预定义值的按钮。

如果查询值如下,则工作正常:

_v = "Button1";

但是一旦查询值为:

_v = "Button 1"; // with spaces
_v = "Button / Button / Button"; // or with slashes

以下查询失败:

$('.club[value=' + _v + ']').addClass('active');

我收到以下错误:

Uncaught Syntax error, unrecognized expression: [value=Button 1]

如何更改查询才能使其不再失败?

最佳答案

您需要用双引号将值括起来

$('.club[value="' + _v + '"]').addClass('active');

关于jquery - 未捕获语法错误,无法识别的表达式 : (spaces and slashes in query),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12266322/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com