이 스크립트를 가지고 특정 div에 추가하고 싶습니다. 지금은 팝업창으로 경고합니다.경고 jquery 도움말, div/span 내에 들어가는 텍스트가 필요합니다.
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);
});
'success && success'? 이것은 새로운 종류의'if' 문입니까? – undefined
@undefined :'success'는'false'로 설정 될 수 있고 JS에서는 올바르게 기억한다면 '&&' 단락 회로를 설정할 수 있습니다. 그것은 (다소 혼란 스럽다) 속기. – Blender