Response title
This is preview!
Hi all, I have the following need: I want to call a js each time an image is loaded on the page but I also need that the DOM of the page is completely loaded before the js runs.
I wrote the following 'dummy' example and I would like to know if it can be considered correct or not. It seems to work but, since jquery says: "The .ready() method is generally incompatible with the body onload attribute", I would like someone to tell me: "yes, you can do that" or "no, you can't do that because..."
<html>
<head>
<script type="text/javascript">
function mySetVal() {
$(document).ready(function () {
$("#status").val("Refreshing");
});
}
</script>
</head>
<body>
<div style="border:1px solid green">
<img src="target.jpeg" id="cat" onload="mySetVal()"></img>
</div>
<p>Input: <input type="text" id="status" /></p>
</body>
</html>
© 2013 jQuery Foundation
Sponsored by and others.