【问题标题】:Syntax error, unrecognized expression: unsupported pseudo语法错误,无法识别的表达式:不支持的伪
【发布时间】:2014-06-16 07:11:53
【问题描述】:

我正在尝试执行以下代码,但它会抛出以下错误消息:

错误:语法错误,无法识别的表达式:不支持的伪: 真的很厉害

代码:

<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">

谁能解释为什么会抛出这个错误?

【问题讨论】:

  • 你为什么使用:really-good-at?支持的伪代码是 :empty, :checked
  • @shaunakde:这是我在论坛上找到的代码。我试图解决加密。所以 :really-good-at 不被支持?
  • :really-good-at 无效。你到底想做什么?
  • @user500468 您应该向论坛所有者提出这个问题..!因不清楚而关闭..!

标签: jquery syntax selector


【解决方案1】:

您可以在此处查看 jQuery 的有效选择器列表:http://api.jquery.com/category/selectors/

您的问题只是 :really-good-at 不是有效的选择器。

如果really-good-at类名,您可以使用.is('.really-good-at')

【讨论】:

【解决方案2】:

好吧,错误很明显...really-good-at 不是公认的 css 伪选择器。您不能只使用任意伪选择器并期望它起作用。这就像我试图在日本说西班牙语并期望日本人理解我在说什么

【讨论】:

    【解决方案3】:

    一个非常相似的经历刚刚发生在我身上,它使用了一个没有意义的伪选择器。问题是......它在我自己的代码中!

    它是这样诞生的: - 最初它是一个有效的 CSS 表达式: “td:第n个类型” 在回调函数中使用,到目前为止一切正常。 直到我决定选择整个函数,并对选定的文本进行大量查找/替换:将“type”替换为“action”。 为什么?因为该回调的参数之一被错误地命名为“type”而不是“action”。这就是我的伪选择器最终成为“nth-of-action”的方式,因此触发了 JS 错误,进而停止处理其余代码。 据我所知,大规模替换是危险的,我仍然查看我的代码以寻找“动作”的实例,但我没有看到伪选择器 nth-of-type 已更改......

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-04-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多