title: How to add onload event to a div using jquery or javascript?
body: <p>hi guys i am trying to call a function on the onload event of a  div but i can't find anything that would help me call a function on the onload event.
  i did try to call it using this "oQuickReply.swap" but it didn't work as that would only swap the position. so can you tell me how can i add a onload event on a div? 
  my question is different as i have a function that can only be called in a loop to take the 'post_id' value to the function the onload event i want is to call my function select_comment() which would get me all the comments from my database to the page. let me show you my code and if there is something you dont understand tell me beforehand i will detail it.</p>
  
  <pre><code>     &lt;script type="text/javascript"&gt;
   $(window).load(function(e){
  
      // grab the scroll amount and the window height
         loadmore();
         select_likes();
  
         select_share();
         // get_recieve_friend_requests();
         // get_sent_friend_requests();
      });
  
   function loadmore(){
            var lastID = $('.load-more').attr('lastID');
           // alert(lastID);
  
                jQuery.ajax({
                    type:'POST',
  
                    url:'&lt;?php echo base_url("user/get_all_post"); ?&gt;',
                     data: {id:  lastID },
                        dataType: 'json', 
  
  
                    beforeSend:function(data){
                        $('.load-more').show();
                    },
                    success:function(data){
  
                           var ParsedObject = JSON.stringify(data);            
                           var json = $.parseJSON(ParsedObject);
  
  
                           if (json=="") {
                            $("#bottom").append('&lt;div class="btn btn-default col-md-6" &gt;'+'No More Results'+'&lt;/div&gt;');
                            $("#Load_more_data").hide()
  
                           }else{
  
                             $postID=json[json.length-1].id;
  
                $('.load-more').attr('lastID', $postID);
  
                  $.each(json, function (key, data) {
  
  
     var post_id=data.id;
      var post_status=data.status;
       var status_image=data.status_image;
      var multimage=data.multimage;
  
  
  
                               if(!post_status=="" &amp;&amp; !status_image==""){
                                 $("#status_data").append('&lt;div class="panel-footer" onload="select_comment('+post_id+');"&gt;&lt;div class="row"&gt;&lt;div class="col-md-12"&gt;&lt;a href="#"&gt;13 people&lt;/a&gt; like this&lt;/div&gt;&lt;/div&gt;&lt;ul class="media-list"&gt;&lt;li   class="media_comment"&gt;&lt;/li&gt;&lt;li class="media"&gt;&lt;div class="media-left media-top"&gt;&lt;?php echo img($user_file_image); ?&gt;&lt;/div&gt;&lt;div class="media-body"&gt;&lt;div class="input-group"&gt;&lt;form action="" id="form_content"&gt;&lt;textarea name="textdata" id="content_comment" cols="25" rows="1"  class="form-control message"  placeholder="Whats on your mind ?"&gt;&lt;/textarea&gt;&lt;button type="submit" id="comment_button" onclick="comment_here('+post_id+');"&gt;Comment&lt;/button&gt;&lt;/form&gt;&lt;/div&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;/div&gt;');                 
  
                      });
                    }
                }
              });
            }
  function select_comment(post_id)
  {
  
    alert(post_id);
  
    var User_id = $('.id_data').attr('value');
   jQuery.ajax({
                    type:'POST',
                    url:'&lt;?php echo base_url("user/select_comment"); ?&gt;',
                    data: {Post_id:Post_id,User_id:User_id},
                    dataType: 'json', 
                    success:function(data)
                    {
                      alert('you have like this');
                    }
            });
  
  }
  </code></pre>
  
  <p>now you see that's how i want to use my function to call when that div loads.</p>