Reputation: 13620
i have a javascript that i need to load at the body, but since im trying to build something flexible i really want it to function on a onLoad on a divtag. But thats not going to happen as i understand it as onLoad does not work on a divtag.
is there another way i can load/start a function within a divtag? or when i include the .js file?
Upvotes: 0
Views: 374
Reputation: 1262
you can embed script snippets which execute when they are loaded. This example is from jquery...
<span class="myclass otherclass">span class="myClass"</span>
<script>$(".myclass.otherclass").css("border","13px solid red");</script>
Maybe you need to make your question more clear?
Upvotes: 1
Reputation: 114447
You can use a timer to check for a change. Not very efficient, but it will work.
That begs the question: What is loading into the DIV? How did it start? Where did it come from? Perhaps these are more worthy of investigation.
If you force the "source" that is changing the element into changing something that has an onchange event, you can certainly trap that. Perhaps routing an intended DIV
change to an INPUT
could solve the problem.
Upvotes: 1