jquery: fire a function when a specific div loads?
I want to fire a function when a specific div is load.
by searching I found thatonload
is not functioning on div .
so I tried it by an image that work perfect But problem is that it fire the function only one time . for example when I refresh the page it fire the function but if I again refresh the page it can't fire the function again.. why is it happened ?
Any suggestio开发者_如何学Gon please
EDIT
<div id="divID">
<img src="myimage.jpg" alt="image"/>
</div>
$('#divID').load(function() {
// code to function
});
You can call the function inside a script tag after the div closing tag Example
<div>
//something inside
</div>
<script type="text/javascript">
//call the function here
functionName();
</script>
If #divID is loading in delay . You can use timeout function as below
setTimeout( function () { //Do something }, 5000); });
5000 is delay of 5 secs
精彩评论