I have 20 x element.selector with same (100px
) height and I need to get their height (100px
, not 2000px
).
What is faster/more efficient to do?
$(".selector").height()
or
$(".selector").eq(0).height()
I have 20 x element.selector with same (100px
) height and I need to get their height (100px
, not 2000px
).
What is faster/more efficient to do?
$(".selector").height()
or
$(".selector").eq(0).height()
I raced them for you.
And it seems, that not using
eq(0)
is slightly faster. It's obvious, because you save another function call on your jquery object. Not calling something is always faster than to call.This is my test case: