Browse - Programming Tips - jQuery: Get first and second instance

Date: 2019sep21
Library: jQuery
Language: javaScript

Q.  jQuery: Get first and second instance

A.
const firstUseOfMyClass = $('.myclass').first(); const secondUseOfMyClass = $('.myclass').eq(1) const thirdUseOfMyClass = $('.myclass').eq(2)
eq() returns a jQuery object which is what you probably want. get() returns the DOM element so is less useful.