Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQuery CSS Selector e.fn.e.init

Tags:

html

jquery

css

Sometimes I use jquery to test my css. And often I'll use a simple selector (in the Chrome Web Developer console)

I'll type in something like $('.topclass div') and get back

e.fn.e.init[125]

As a javascript object containing nodes. (Usually its quite a complex selector but sometimes its simple).

Why do I get this? Does it mean a tag is missing or my selector is wrong?

Edit: The html is basically nested divs (could it be because its getting its children divs too?)

like image 936
Tarang Avatar asked May 28 '12 09:05

Tarang


1 Answers

It means your selection contains too many matches, and the developer tools shorten their representation in the console.

Try this in the console:

var a = []
for (var i = 0; i < 10; i++) { a.push('foobar'); }

If you try to inspect a, you will see ["foobar", "foobar", "foobar", "foobar", "foobar", "foobar", "foobar", "foobar", "foobar", "foobar"]. Now, add some more elements:

for (var i = 0; i < 100; i++) { a.push('foobar'); }

Now, if you try to inspect it, you will see Array[110].

Does not inherently mean your selector is wrong, but if you're expecting fewer elements, then it might be wrong.

like image 145
lanzz Avatar answered Oct 14 '22 08:10

lanzz