Get DOM element from jQuery object 

Joined:
02/21/2009
Posts:
130

June 22, 2010 21:09:20    Last update: June 22, 2010 21:10:14
Inside event handlers refer to the DOM element as 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)
Share |
| Comment  | Tags