jquery load div after page load

房东的猫 提交于 2019-11-30 10:51:39
$(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.

Kaszoni Ferencz

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 ;)

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!