<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> <script> jQuery.fn.extend({ hoge: function() { return this.text('hoge') } }); $(function() { $(document).on('DOMNodeInserted', '#divHoge', function() { $(this).hoge() }); /* $('#divHoge').live('DOMNodeInserted', function() { $(this).hoge() }) */ setTimeout(function() { document.body.innerHTML = '<div id="divHoge">piyo</div>'; }, 1000); }); </script> </head> <body> </body> </html>
jQueryのbind/live/delegateの違いまとめ、と新API .on()の使い方 - y-kawazの日記