xxxpara
V2EX  ›  jQuery

为什么能在浏览器控制台使用两个$$()这样的的选择器?

  •  
  •   xxxpara · Jul 10, 2015 · 4149 views
    This topic created in 4015 days ago, the information mentioned may be changed or developed.

    这个应该不是jQuery自带的选择器吧,可是直接在控制台可以使用,在js文件里却提示 $$ is not defined

    6 replies    2015-07-10 19:38:51 +08:00
    b1
        1
    b1  
       Jul 10, 2015
    浏览器自带,相当于querySelectorAll(
    phy25
        3
    phy25  
       Jul 10, 2015
    再来个 Chrome 的: https://developer.chrome.com/devtools/docs/console#selecting-elements

    通用的函数是 $, $$, $x,FireFox 的 helper 函数更多一些。
    bertonzh
        4
    bertonzh  
       Jul 10, 2015   ❤️ 2
    因为 Chrome 在控制台执行脚本,实际上运行的都是:
    ```
    with(__commandLineAPI) {
    xxx
    }
    ```

    而这些方法都是 __commandLineAPI 内置的。
    xxxpara
        5
    xxxpara  
    OP
       Jul 10, 2015
    @phy25
    @bertonzh
    @bugoftime
    谢谢,明白了!
    lujiajing1126
        6
    lujiajing1126  
       Jul 10, 2015 via Android
    最近好多类似的commandline的问题~
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1128 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 37ms · UTC 18:09 · PVG 02:09 · LAX 11:09 · JFK 14:09
    ♥ Do have faith in what you're doing.