today came across in code:
$($($(this).children()[1])).css("border-color", "#fff");
i haven't seen before, , best of understanding, writing following accomplish same thing:
$(this).children()[1].css("border-color", "#fff");
is there purpose top way (is better?), or knowing doing jquery?
the second expression won't same thing, because accessing array elements of jquery collection returns dom node, not jquery object, , can't call jquery methods on it. actual equivalent be:
$(this).children().eq(1).css("border-color", "#fff");
the first code equivalent to:
var temp = $(this).children()[1]; // dom node of 2nd child $(temp).css("border-color", "#fff"); // wrap in jquery object , set css
Comments
Post a Comment