chhameed chhameed - 1 year ago 39
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

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


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

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

Answer Source

You can call the function inside a script tag after the div closing tag Example

//something inside

<script type="text/javascript">
//call the function here