chhameed chhameed - 5 months ago 8
Javascript Question

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 that

onload
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 suggestion please

EDIT

<div id="divID">
<img src="myimage.jpg" alt="image"/>
</div>

$('#divID').load(function() {
// code to function
});

Answer

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>