2016-06-20 30 views
0

我有一個div,它有很多內容。我想在div的內容發生變化時顯示警報(div每60秒刷新一次)。我嘗試$(「div#divName」)。html(),但它不工作,因爲div有一個大內容。那麼我做了什麼?如何獲得大div的html

var $container = $("#load-scores"); 
$container.load("/include/home.php?ust=" + url_site + "&tz=" + tz); 
    var s= $("#load-scores").html(); 
var refreshId = setInterval(function() 
{ 
    $container.load("/include/home.php?ust=" + url_site + "&tz=" + tz); 
    var p = $('#load-scores').html(); 
    if(p.is(s)) 
     alert("changed"); 
}, refresh_time); 

PS: 的console.log(p)和執行console.log(S)是返回空

+0

分享代碼。 –

+0

分享一些代碼,如何讓人耳目一新? – hsh

+0

我已添加代碼 –

回答

1

您可以使用jQuery的load()的函數。

var $container = $("#load-scores"); 
$container.load("/include/home.php?ust=" + url_site + "&tz=" + tz, function(){ 
     alert("Changed"); 
    }); 
var refreshId = setInterval(function() 
{ 
    $container.load("/include/home.php?ust=" + url_site + "&tz=" + tz, function(){ 
     alert("Changed"); 
    }); 

}, refresh_time);