with jquery,how can i do something just after the dom loaded,i write like this:
<script>
$("#google").load(function() {
alert('ok');
});
</script>
<img src="http://www.google.com/images/logos/ps_logo2.png" id="google" />
but nothing happen~
if i use ready() instead of load like this:
<script>
$("#google").ready(function() {
alert(this);
alert('ok');
});
</script>
<img src="http://www.google.com/images/logos/ps_logo2.png" id="google" />
,it will work ,but the pointer “this” will not be $(“#google”),and it seems to be “window” or other things,i feel confused~
You should first bind the event handler to the load event, then set the image’s src to actually start the load.
see this: http://jsfiddle.net/VaLhf/