【发布时间】:2014-01-22 13:56:15
【问题描述】:
在这里,我有一个脚本,它使用 google places api 向我显示对象的开放时间。 http://jsbin.com/ATaZEXE/4
现在我想将 .label 类的背景颜色更改为“红色”,如果 place.open_now 为 false,如果为 true,则必须保持不变
我该怎么做?
使用此代码,我检查对象的 opening_hours,但如果 place.open_now 为 false,如何更改颜色?
(function(marker,request,i){
setTimeout(function(){
service.getDetails(request, function(place, status){
try{
var time=place.opening_hours.periods[1].open.time;
var closed=place.opening_hours.periods[1].close.time;
var closed=[(closed/100).toFixed(0),closed.substr(-2)].join(':');
marker.set('labelContent',[(time/100).toFixed(0),time.substr(-2)].join(':')+' - '+closed+'</br>'+place.name);
}
catch(e){}
});
},
i*250)
})(marker,request,i);
我需要在哪里添加IF 语句来检查是place.open_now 是真是假,如果place.open_now 是假的,如何更改背景?
*来自谷歌的地方 api 文档: opening_hours 可能包含以下信息: open_now 是一个布尔值,指示地方是否在当前时间开放。*
【问题讨论】:
标签: javascript css function google-maps google-places-api