How can we use jQuery .on() method with load event? e.g. The code is:
<a href="#" id="add">Add</a>
<div id="initial">
<input type="text" class="abc" name="in">
</div>
And the jQuery for it:
jQuery(document).ready(function() {
var x=$('#initial').html();
$('#add').click(function(){
$('body').append(x);
});
$(document).on('load','.abc',function(){
alert('started');
});
});
Refer to http://api.jquery.com/on/
It says
If you want to do something when a new input box is added then you can simply write the code after appending it.
And if you want the same code execute when the first input box within the document is loaded then you can write a function and call it in both places i.e.
$('#add').clickand document’s ready event