Bug Tracker

Opened 15 years ago

Closed 13 years ago

Last modified 9 years ago

#2977 closed bug (fixed)

wrap() methods lose events

Reported by: rodnaph Owned by:
Priority: minor Milestone: 1.4
Component: core Version: 1.4a1
Keywords: clone wrap events Cc:
Blocked by: Blocking:


When using the wrap() method, events I have added to the element are lost (because wrap() uses clone() which doesn't preserve events). Shouldn't jQuery actually preserve events on elements? (or atleast provide the option to preserve them without having to rely on a plugin?)


$( 'img' ).wrap(

$( '<a></a>' )

.click( doSomething )


Change History (6)

comment:1 Changed 15 years ago by rodnaph

This bug is also in 1.2.6.

comment:2 Changed 14 years ago by skorpan

Actually, I seem to have an even worse problem.

var jq = $(elem);
var div = $('<div></div>');
div.click(function () {

I click the DIV - nothing happens. So it seems that whenever I use wrap() on a JQuery object, I can't bind any events to it whatsoever. Tested in Firefox 3.0.1 on Windows XP.

comment:3 Changed 14 years ago by dmethvin

Keywords: clone wrap events added

comment:4 Changed 14 years ago by matejr

Please, fix this issue. It's just about adding true as parameter of the clone function called from wrapAll function.

comment:5 Changed 13 years ago by john

Milestone: 1.31.4
Resolution: fixed
Status: newclosed

comment:6 Changed 9 years ago by [email protected]


Still can reproduce this bug http://jsfiddle.net/VDQmC/3/


Note: See TracTickets for help on using tickets.