$0-$4 未在 Chrome 控制台中记录最后选择的 DOM 个元素

$0-$4 not recording last selected DOM elements in Chrome console

我在 Chrome 命令行 API 上了解到,我可以在终端中使用 [=13=]-4 来获取最近选择的 DOM 对象。但是,我无法让它按预期工作。

$("#ev");
[<button type=​"button" id=​"ev">​Event attached to this button​</button>​]
console.log([=12=]) //<body></body>

看起来第 2 行返回了一个数组,尽管我的印象是 $document.querySelector(...) 的别名。所以我也试过 $("#ev")[0] 但没有更好的运气。这是如何被错误使用的?

您必须单击 Elements 面板中的元素才能将其保存在 [=11=] 中。来自 Using the Console:

Accessing recently selected elements and objects
The console stores the last five element and object selections. As you select an element in the Elements panel or an object in the Profiles panel, that pushes onto the history stack. $x provides access to the history stack. Remember computers begin counting from 0; this means the latest item is [=11=] and the oldest item is .