我试图检查CSS属性从输入到表格单元格。输入在点击时出现,在失去焦点时消失,就像我试图检查它一样。 当我移动到另一个窗口(检查器)时,我如何做到不失去焦点?


当前回答

将以下Javascript代码粘贴到浏览器开发控制台:

// Delayed console log of parent element with disappearing child element(s)
// Once code is trigger, you have 3 seconds to trigger the hidden element before it snapshots.
// The hidden elements should appear in the console ready to inspect.

var timer = 3000; //time before snapshot
var parent_of_element_to_inspect = 'div.elementcontainer'; //container of element to snapshot
setTimeout(function(){
 console.log(document.querySelector(parent_of_element_to_inspect).cloneNode(true));
},timer);

其他回答

在Chrome浏览器中,打开开发人员工具,然后选择元素选项卡 打开你想要检查的元素的父节点的上下文菜单,在上下文菜单中单击>子树修改上的Break。

之后,你只需要点击页面,你就会进入检查器,而不会失去焦点或失去你想要检查的元素。

不是一个真正的解决方案,但它通常是有效的。

聚焦元素 右击上下文菜单 转到开发人员工具

将以下Javascript代码粘贴到浏览器开发控制台:

// Delayed console log of parent element with disappearing child element(s)
// Once code is trigger, you have 3 seconds to trigger the hidden element before it snapshots.
// The hidden elements should appear in the console ready to inspect.

var timer = 3000; //time before snapshot
var parent_of_element_to_inspect = 'div.elementcontainer'; //container of element to snapshot
setTimeout(function(){
 console.log(document.querySelector(parent_of_element_to_inspect).cloneNode(true));
},timer);

我遇到了一个非常困难的情况,这里没有答案(我没有验证改变容器的答案,这是我的主体,或原始事件,因为我不知道)。我终于找到了一个解决办法,通过控制事件监听断点在Chrome检查器。也许这也是一种跨浏览器的方式打破复杂的情况下,甚至F8或右键单击鼠标隐藏弹出再次:

如果所有这些都失败了,在控制台中输入以下内容:

setTimeout(() => { debugger; }, 5000)

然后,您有5秒钟的时间(或将值更改为其他任何值)来显示您想要调试的任何内容。

其他的答案都对我不起作用——DOM树在脚本暂停之前一直被修改(即我关心的东西消失了)。