I'm trying to assign some attributes to some html tags as soon as they load to the page by Ajax, but I don't want to write any Javascript in my page. foe example I have the the html like below:(remember that this comes via ajax, not on page load)
<div data-something="true">
something here
</div>
and I want to have something like this which is saved to a .js file: (this doesn't work)
$('body').on('load', '[data-something]', function(){
//do something
});
but I do NOT want to have like this in one page :
<div data-something="true">
something here
</div>
<script>
$(function(){
//do something
});
</script>
is there anyway to do so? to trigger the event as soon as the element being loaded?