警报 jquery 帮助,需要其文本进入 div/span



我有这个脚本,想把它添加到一个特定的div。 现在它只是通过弹出窗口发出警报。

function getTime(zone, success) {
    var url = 'http://json-time.appspot.com/time.json?tz=' + zone,
        ud = 'json' + (+new Date());
    window[ud]= function(o){
        success && success(new Date(o.datetime));
    };
    document.getElementsByTagName('head')[0].appendChild((function(){
        var s = document.createElement('script');
        s.type = 'text/javascript';
        s.src = url + '&callback=' + ud;
        return s;
    })());
}
getTime('US/Hawaii', function(time){
    // This is where you do whatever you want with the time:
    alert(time);
});

javascript:

$("div#specific_id").append(time);

.html:

<div id="specific_id">the time will be added after this text</div>

我想你应该看看文档

编辑:@Blender制作了这个帮助片段,以明确一切:http://jsfiddle.net/eytkU/2/

最新更新