Use the delegate style for .on
.on( events [, selector ] [, data ], handler )
- events Type: String One or more space-separated event types and optional namespaces, such as "click" or "keydown.myPlugin".
- selector Type: String A selector string to filter the descendants of the selected elements that trigger the event. If the selector is
null or omitted, the event is always triggered when it reaches the
selected element.
- data Type: Anything Data to be passed to the handler in event.data when an event is triggered.
- handler Type: Function( Event eventObject [, Anything extraParameter ] [, ... ] ) A function to execute when the event is
triggered. The value false is also allowed as a shorthand for a
function that simply does return false.
As you don't want to pass data, you can write in form:
$(body).on('click', 'p', handler)
which omits the data param.
$("body").on("click", "p", function(){
alert("The paragraph was clicked.");
$("body").append("<p>This was newly added. this has also click</p>")
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<p>Click this paragraph.</p>
$(document).on('click', 'p', handler);