Im trying to execute the following code below, but it throws the following error message:
我正在尝试执行下面的代码,但是它会抛出以下错误消息:
Error: Syntax error, unrecognized expression: unsupported pseudo: really-good-at
错误:语法错误,无法识别的表达式:不支持的伪:真的很好
The code:
代码:
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script type="text/javascript">
/* Implement a Cesar crypto decrypt for the code.
* [Code ASCII] + n => Decrypted ASCII.
* where n = char pos in cryptedCode string (R=1) */
if ($('.js.php.mysql.html.oop').is(':really-good-at')) {
var cryptedCode = 'RFLLDN';
var decryptedCode = '';
console.log('Enter this code in the form: ' + decryptedCode);
//Open website url
var url = 'aHR0cDovL2JpdC5seS8xN21NRzk4';
window.open(window.atob(url));
}
</script>
<input type="text" class="js.php.mysql.html.oop">
Anyone who can explain why this error is thrown?
谁能解释为什么会抛出这个错误?
3 个解决方案
#1
10
You can see jQuery's list of valid selectors here: http://api.jquery.com/category/selectors/
您可以在这里看到jQuery的有效选择器列表:http://api.jquery.com/category/selectors/
Your problem is simply that :really-good-at
is not a valid selector.
你的问题很简单:做得好不是一个有效的选择。
If really-good-at
is a class name, you could use .is('.really-good-at')
如果re- good-at是类名,可以使用.is('. rely -good-at')
#2
2
Well, the error is clear...really-good-at
is NOT a recognized css pseudo selector. You can't just use arbitrary pseudo selectors and expect it work. It's like me trying to speak Spanish in Japan and expecting japanese people to understand what I'm saying
错误很明显……真的-好-at不是一个公认的css伪选择器。你不能只使用任意的伪选择器并期望它工作。就像我在日本讲西班牙语,希望日本人能理解我在说什么
#3
0
A very similar experience just happened to me with a pseudo selector that just didn't make sense. The problem is...it was in my own code!
我也有过类似的经历,一个伪选择器没有意义。问题是……这是我自己的密码!
This is how it was born: - initially it was a valid CSS expression: "td:nth-of-type" used within a callback function, so far so normal. Until I decided to select the whole of that function, and do a massive find/replace on the selected text: replace "type" with "action". Why? Because one of the arguments of that callback was wrongly named "type" instead of "action". This is how my pseudo selector ended up as "nth-of-action", hence triggering a JS error, which in turn stopped processing the rest of the code. As much as I know by experience that massive replaces are dangerous, I still reviewed my code to look for instances of "action", but I didn't see that the pseudo selector nth-of-type has been changed...
这就是它是如何诞生的:-最初它是一个有效的CSS表达式:“td:nth- type”,在回调函数中使用,到目前为止是正常的。直到我决定选择整个函数,并对选中的文本进行大量的查找/替换:用“action”替换“type”。为什么?因为回调的一个参数被错误地命名为“type”而不是“action”。这就是我的pseudo选择器最终以“nth-of-action”结束的原因,从而触发一个JS错误,从而停止处理其余的代码。根据经验,我知道大规模替换是危险的,我仍然检查我的代码以查找“action”的实例,但是我没有看到伪类型选择器n -type已经更改……
#1
10
You can see jQuery's list of valid selectors here: http://api.jquery.com/category/selectors/
您可以在这里看到jQuery的有效选择器列表:http://api.jquery.com/category/selectors/
Your problem is simply that :really-good-at
is not a valid selector.
你的问题很简单:做得好不是一个有效的选择。
If really-good-at
is a class name, you could use .is('.really-good-at')
如果re- good-at是类名,可以使用.is('. rely -good-at')
#2
2
Well, the error is clear...really-good-at
is NOT a recognized css pseudo selector. You can't just use arbitrary pseudo selectors and expect it work. It's like me trying to speak Spanish in Japan and expecting japanese people to understand what I'm saying
错误很明显……真的-好-at不是一个公认的css伪选择器。你不能只使用任意的伪选择器并期望它工作。就像我在日本讲西班牙语,希望日本人能理解我在说什么
#3
0
A very similar experience just happened to me with a pseudo selector that just didn't make sense. The problem is...it was in my own code!
我也有过类似的经历,一个伪选择器没有意义。问题是……这是我自己的密码!
This is how it was born: - initially it was a valid CSS expression: "td:nth-of-type" used within a callback function, so far so normal. Until I decided to select the whole of that function, and do a massive find/replace on the selected text: replace "type" with "action". Why? Because one of the arguments of that callback was wrongly named "type" instead of "action". This is how my pseudo selector ended up as "nth-of-action", hence triggering a JS error, which in turn stopped processing the rest of the code. As much as I know by experience that massive replaces are dangerous, I still reviewed my code to look for instances of "action", but I didn't see that the pseudo selector nth-of-type has been changed...
这就是它是如何诞生的:-最初它是一个有效的CSS表达式:“td:nth- type”,在回调函数中使用,到目前为止是正常的。直到我决定选择整个函数,并对选中的文本进行大量的查找/替换:用“action”替换“type”。为什么?因为回调的一个参数被错误地命名为“type”而不是“action”。这就是我的pseudo选择器最终以“nth-of-action”结束的原因,从而触发一个JS错误,从而停止处理其余的代码。根据经验,我知道大规模替换是危险的,我仍然检查我的代码以查找“action”的实例,但是我没有看到伪类型选择器n -type已经更改……