开发者

jquery load div after page load

开发者 https://www.devze.com 2023-02-16 14:46 出处:网络
Actually what I am looking for loading is loading the page first and then a div with l开发者_运维知识库ots of data. So, I want to load the main page first and then body div content using jQuery functi

Actually what I am looking for loading is loading the page first and then a div with l开发者_运维知识库ots of data. So, I want to load the main page first and then body div content using jQuery function with some delay.

What is the simple way of implementing this..?

 <div id="container">
      <div id="header">navigation</div>
      <div id="body" class="body">Body</div>
      <div id="footer">footer</div>
 </div>


$(document).ready(function(){

  $.get('ajax/page.php', function(data) {
    $('#body').html(data);
  });

});


The shorthand version:

$(function(){
 $("#body").html();
 //...
});

If you want to do it after an interval

function load(){
 $("div").html(...);
}
$(function(){
  // Interval of 5 secs.
  setInterval("load()",5000);
  //http://www.w3schools.com/jsref/met_win_setinterval.asp
});


$(document).ready(function() {
  // Handler for .ready() called.
});

The ready function is called when page is fully loaded. You can load your div in it.


This is what I've done:

function newContent()
{
    $("#navix").load("new1.php");
}
$(function(){
  // Interval of 5 secs.
  setInterval("newContent()",5000);
  //http://www.w3schools.com/jsref/met_win_setinterval.asp
});

It works great ;)

0

精彩评论

暂无评论...
验证码 换一张
取 消