Skip to content

Instantly share code, notes, and snippets.

@sh19910711
Created December 14, 2012 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sh19910711/4285784 to your computer and use it in GitHub Desktop.
Save sh19910711/4285784 to your computer and use it in GitHub Desktop.
DOMNodeInserted
$( function( ) {
/**
* 指定したクラスを持つ要素が追加されたら発火させる
*/
$( 'body' ).on( 'DOMNodeInserted', function( event_info ) {
var element = $( event_info.target );
if ( element.hasClass( 'test' ) ) {
console.log( element.text( ) );
}
} );
(function( ) {
$( 'body' ).append( '<div class="test">test 1</div>' );
$( 'body' ).append( '<div class="test">test 2</div>' );
})( );
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment