Get DOM element from jQuery object
June 22, 2010 21:09:20 Last update: June 22, 2010 21:10:14
Inside event handlers refer to the DOM element as
Or, use the
this:
$('#theButton').click(function() { this.innerHTML = 'You Clicked!'; });
Or, use the
.get() method outside:
// return the whole list $('li').get(); // return the first item $('li').get(0); $('li')[0] // return the last item $('li').get(-1)