【问题标题】:jQuery :input selector in Chrome Extension's Content scriptjQuery:Chrome 扩展内容脚本中的输入选择器
【发布时间】:2015-09-15 06:56:03
【问题描述】:

我正在尝试在内容脚本中执行此操作

console.log('Found ' + $(':input').length + 'inputs');

我明白了

未捕获的语法错误:无法在“文档”上执行“querySelectorAll”:“:输入”不是有效的选择器。

【问题讨论】:

    标签: javascript jquery google-chrome-extension


    【解决方案1】:

    发生错误是因为您的内容脚本中似乎没有可用的 jQuery。但是在 Chrome 开发者控制台中,$document.querySelector 方法的内置符号快捷方式。

    因此,当您运行 $(':input') 时,它等同于 document.querySelector(':input'),这当然会引发上述异常,因为 :input 不是有效的 CSS 选择器。

    【讨论】:

    • 我明白了,但是有 jQuery。
    • 我对@9​​87654327@也有同样的感觉
    • 什么是console.log( jQuery.fn.jquery )
    • 2.1.1 -deprecated,-dimensions,-effects,-effects/Tween,-effects/animatedSelector,-event-alias,-offset,-css/hiddenVisibleSelectors,-wrap
    猜你喜欢
    • 2012-07-08
    • 2023-03-21
    • 1970-01-01
    • 2022-08-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-15
    相关资源
    最近更新 更多