Bug Tracker

Modify

Ticket #10830 (closed bug: worksforme)

Opened 18 months ago

Last modified 18 months ago

:first selector in delegate/on doesn't work

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

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

comment:1 Changed 18 months ago by timmywil

  • Priority changed from undecided to low
  • Resolution set to worksforme
  • Status changed from new to closed
  • Component changed from unfiled to event

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

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

comment:2 Changed 18 months ago by dmethvin

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

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.