Chrome无法再从脚本中记录可检查的jQuery对象 [英] Chrome can no longer log inspectable jQuery objects from scripts

查看:191
本文介绍了Chrome无法再从脚本中记录可检查的jQuery对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

在最新稳定的Chrome 23.0.1271.101和Chrome Canary 26.0.1373.0中,从脚本运行以下代码:

In the latest stable Chrome 23.0.1271.101, and Chrome Canary 26.0.1373.0, running the following code from a script:

$(function(){
    console.log( $('body') )
})

现在返回:

[<body>, prevObject: jQuery.fn.jQuery.init[1], context: #document, selector: "body"]


$ b

Hovering over this log out does nothing, it is not inspectable.

这个交互式控制台仍然可以工作,例如键入:

The interactive console still works, eg, typing:

console.log( $('body') )

会正确回应:

[<body>...</body>]

当鼠标悬停在日志输出上时,可以检查它,因为以前的Chrome版本

When the mouse is hovered over the log output it can be inspected, as previous versions of Chrome used to do for scripts.


  • 是否有一种方法可以使Chrome日历可检测元素的每个先前版本的Chrome,而且交互式控制台仍然?

  • 是否有新版本或较旧版本的Chrome没有此错误?

推荐答案

要实现Chrome以前的做法,请将 [0] 附加到函数。

To achieve what Chrome previously used to do, append [0] to the function.

正如 JanDvorak 指出的,这在所有情况下可能无效,并且只提供第一个元素,但在某些情况下工作。

As pointed out by JanDvorak, this may not work in all cases, and provide only the first element, but works in some cases.

$(function(){
    console.log($('body')[0]);
});

更新

这里,是由 jquery.chromelog / users / 514749 / pimvdb> pimvdb ,这似乎还行。

From here, there is a jQuery plugin jquery.chromelog made by pimvdb, which seems the way to go.

这篇关于Chrome无法再从脚本中记录可检查的jQuery对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆