如何在 Chrome 中 console.log 一个 jQuery DOM 元素? [英] How do I console.log a jQuery DOM Element in Chrome?

查看:34
本文介绍了如何在 Chrome 中 console.log 一个 jQuery DOM 元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我曾经能够执行 console.log(somejQueryObj); 并且它将对象中的所有 DOM 元素都记录在一个数组中,我可以单击并转到检查器.

I used to be able to do console.log(somejQueryObj); and it logged in an array all of the DOM elements that are in the object that I could click and go to the inspector.

现在它做了这样的事情:

Now it does something like this:

[prevObject: p.fn.p.init[1], context: , selector: ".next()"]

[prevObject: p.fn.p.init[1], context: , selector: ".next ()"]

这会让很多人感到困惑.

如何让 Chrome 记录它用于记录 jQuery 元素的方式?

How do I make it so that Chrome logs how it used to log jQuery elements?

这是一个小提琴示例

我在:

谷歌浏览器 23.0.1271.97(官方版本 171054)m

Google Chrome 23.0.1271.97 (Official Build 171054) m

推荐答案

更新:我制作了一个 jQuery 插件来恢复旧样式的日志记录:jquery.chromelog.

Update: I made a jQuery plugin to bring back the old style logging: jquery.chromelog.

您可以创建一个小函数来记录一行中的所有元素:

You could create a little function to log all elements on one line:

$.fn.log = function() {
  console.log.apply(console, this);
  return this;
};

用法:

$("...").log();

这篇关于如何在 Chrome 中 console.log 一个 jQuery DOM 元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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