Assuming i have a <div class="test" style="width:200px"></div>
,Please consider the following:
var m = $('.test')[0];
var $md = $(m);
console.log($md.width()); //200
var o = $('.test');
console.log(o.width()); // 200
console.log(m); // <div class="test" style="width:200px">
console.log($md); // Object{ context: <div.test> ..... }
console.log(o); // Object{ length:1 , ..... }
Basically i can apply the width
method on either var $md
or var o
, so what's the difference between the 1st and 2nd way if the output is the same?
I see that both md
and o
are objects, but in the console output they not exactly the same, how do they differ? thanks.