How to trigger click on dynamically created element

Richerd fuld picture Richerd fuld · Sep 2, 2015 · Viewed 27.8k times · Source

I know we can bind event to dynamically created elements like below

$('some').on('click','class/id of dynamic ele',function(){});

but how to trigger click event on dynamically created element like i have created new element in dom

<div class="one">M</div>

now how can i $( ".one" ).trigger( "click" ); ?

Answer

Brownman Revival picture Brownman Revival · Sep 2, 2015
$(document).on('click', '.one', function() {

use this one to put click on dynamically created element

find the DOCUMENTATION for more info