I'm requesting DOM-elements .my-element
which come rendered from server and append 'em on my page.
Every time new element appears on the page I want to call JS-function myFunction
.
I want to call this function "automatically" without using excess JS-code.
That's how I do it now. Every rendered element contains tag script
with function call inside:
<div class="my-element">
/*some structure*/
<script>myFunction();</script>
</div>
But I wonder: is there some HTML-attribute who could do the same? Some like that:
<div class="my-element" javascript="myFunction();">/*some structure*/</div>
UPD
I don' want to call myFunction
with the code which appending new items. I want to solve this task exactly using tag script
or some magic attribute.