Created
December 14, 2012 14:23
-
-
Save sh19910711/4285784 to your computer and use it in GitHub Desktop.
DOMNodeInserted
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$( 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