我有这个脚本,并希望将其添加到特定的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);
});
答案 0 :(得分:1)
的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/