Amir Hesari Amir Hesari - 2 months ago 7
jQuery Question

How can add html to div after load page?

How can add html to div after load page?
This HTML:

<div id="information-box"> </div>


And this jQuery:

$("#Step-02").find('#information-box', function () {
for(i = 0; i < lenHotel; i++) {
$("#Step-02").find('#information-box').html(
// HTML
);
}
})

Answer

Just do it when the page is loaded... There's a few ways, but the easiest is to use the jquery shorthand for doing so:

    $(function(){
       $("#Step-02").find('#information-box', function () {
      for(i = 0; i < lenHotel; i++) {
        $("#Step-02").find('#information-box').html(
            // HTML
        );
      }
    })
  });