DIV onload ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hash4sp
    New Member
    • Aug 2007
    • 55

    DIV onload ?

    Hi folks,

    How can I do something as follows:

    Code:
    <div id='resultDIV' onload='funcX()'></div>
    Here, I want to trigger funcX(), when some text is loaded in the div's innerHTML dynamically.

    Through jquery I tried the following, but unsuccessfull.

    Code:
    $("#resultsDIV").load(function() {
        alert("The div has been loaded.");
    });
    best regards
  • JKing
    Recognized Expert Top Contributor
    • Jun 2007
    • 1206

    #2
    There is no onload event for divs

    This is straight from the jquery site for the load()
    "This event can be sent to any element associated with a URL: images, scripts, frames, iframes, and the window object."

    I am sure there is an alternate solution for your problem if you could explain it with a little more detail.

    Comment

    • Luis García
      New Member
      • Sep 2010
      • 3

      #3
      You could implement something like JQuery to do this.

      Comment

      • kovik
        Recognized Expert Top Contributor
        • Jun 2007
        • 1044

        #4
        Since you are using jQuery, you can make use of their .bind() and .trigger() methods.

        i.e.
        Code:
        <script>$(document).bind('divIsReady', function() {
          alert('Div is ready');
        });</script>
        
        ...
        
        <div id="the-div">Content</div>
        <script>$(document).trigger('divIsReady');</script>
        This is useful for when you need certain things to be handled before the rest of the page is loaded.

        Comment

        Working...