Javascript examples for jQuery Method and Property:trigger
call jQuery function in <div> onload attribute
<html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> </head> <body> <div id="dynamic"></div> <script> $(function () {//from w ww .j a v a2s . c o m var div = '<div onload="myfunction()">Here</div>' ; $("#dynamic").html(div); $('div[onload]').trigger('onload'); }); function myfunction(){ console.log('Div is loaded ..'); } </script> </body> </html>