javascript - clone content tag <template> in jQuery -


i'm trying clone contents of tag jquery, i'm unable copy events linked child elements, how can it?

you can use clone() method, setting both withdataandevents , deepwithdataandevents parameters true:

var $templateclone = $('template').clone(true, true); 

see: http://api.jquery.com/clone/

or alternatively, can use plain clone() method no parameters, , use event delegation bind events common parent instead.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -