如何在Chrome中console.log一个jQuery DOM元素? [英] How do I console.log a jQuery DOM Element in Chrome?
问题描述
我曾经可以执行 console.log(somejQueryObj);
并且它将数组中的所有DOM元素都记录在数组中,我可以点击然后去检查员。
现在它的确如此:
[prevObject:p.fn.p.init [1],context:,selector:.next()]
其中可能会混淆许多人。
我该如何做到这一点Chrome记录了它如何记录jQuery元素?
我在:
Google Chrome 23.0.1271.97(官方Build 171054)m
更新:我制作了一个jQuery插件来恢复旧式日志记录: jquery.chromelog 。
你可以创建一个小函数在一行记录所有元素:
$。fn.log = function(){
console.log。应用(console,this);
返回此;
};
用法:
$( ...)日志()。
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 ()"]
which can confuse many people.
How do I make it so that Chrome logs how it used to log jQuery elements?
I am in:
Google Chrome 23.0.1271.97 (Official Build 171054) m
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;
};
Usage:
$("...").log();
这篇关于如何在Chrome中console.log一个jQuery DOM元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!