Why eq(0) returns an array AND no attributes property?
I'm using this function to get the first jquery object:
- function getfirst(selector)
- {
- var selected = $(selector).eq(0);
- return selected;
- }
This works for me almost everywhere. It returns an jquery object which has "attributes" property.(And so many other properties). The attributes can be enumerated
When I want to get an object of table using an 'id' like this:
It returns an object has property "0" "length" and "prevObject". It doen't have "attributes" object.
property "0" is a DOM object. I've tried $(xxx[0]) to convert it to jquery object again. It works well, but I still get the same object.
- //console test result
- obj[0]; //DOM object
- obj.length=1;
- obj.attributed === undefined;
- obj.attr('id') == '#tableMain'; //it works well, and returns the correct id
- obj.id== undefined;
What's wrong with it? Is it because I'm using datatable plugin? how to resolve it ?