Bug Tracker

Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#10830 closed bug (worksforme)

:first selector in delegate/on doesn't work

Reported by: anonymous Owned by:
Priority: low Milestone: None
Component: event Version: 1.7
Keywords: Cc:
Blocked by: Blocking:

Description

Markup:

<div id="test">
	<a href="#">First Child</a>
	<a href="#">Second Child</a>
</div>

jQuery:

var parent = $('#test');

parent.delegate('a:first', 'click', function(e){
	e.preventDefault();
	alert('clicked on the first child');
});

Change History (2)

comment:1 Changed 7 years ago by timmywil

Component: unfiledevent
Priority: undecidedlow
Resolution: worksforme
Status: newclosed

http://jsfiddle.net/timmywil/yf5g3/

Works for me. But I recommend using :first-child instead.

comment:2 Changed 7 years ago by dmethvin

Definitely use :first-child, see #10800 for some background.

Note: See TracTickets for help on using tickets.