Skip to main content

Bug Tracker

Side navigation

#10830 closed bug (worksforme)

Opened November 18, 2011 05:35PM UTC

Closed November 18, 2011 05:40PM UTC

Last modified November 18, 2011 05:46PM UTC

: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');
});
Attachments (0)
Change History (2)

Changed November 18, 2011 05:40PM UTC by timmywil comment:1

component: unfiledevent
priority: undecidedlow
resolution: → worksforme
status: newclosed

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

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

Changed November 18, 2011 05:46PM UTC by dmethvin comment:2

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