Reputation: 3224
What does the [0] mean? Also is there a reference/manual that i can use to prevent asking simple questions like this..
var height = $('.string-parent-container')[0].scrollHeight;
$('.string-parent-container').scrollTop(height);
Upvotes: 0
Views: 543
Reputation: 18339
A different way that returns a jquery object (as opposed to an HTMLElement) would be:
$('.string-parent-container:eq(0)')
// returns the first object with that class
This allows you to do something like
$('.string-parent-container:eq(0)').show()
$('.string-parent-container:eq(0)').addClass('newclass')
etc
Upvotes: 1
Reputation: 60486
It means the first element that matches $('.string-parent-container')
$('.string-parent-container')
returns a collection of elements with the class string-parent-container
. And [0]
is the first element that has this class.
Upvotes: 3