amateur
amateur

Reputation: 44605

fire event when div loads

I have a div on a page. I want to with jquery, when the div loads a function is fired and I can alter its style based on a set of conditions. Any help with this?

Upvotes: 0

Views: 339

Answers (2)

Alex
Alex

Reputation: 1337

well you could try

<div>...content...</div>
<script>functionToRunWhenDivIsLoaded()</script>

Upvotes: 0

AndreKR
AndreKR

Reputation: 33658

The usual way is to do this, when the DOM is ready.

Put this somewhere in a <script>:

$(function() {

    $('#id_of_div').css({...});

});

Upvotes: 1

Related Questions