I'm currently building a website for a shop which has the following opening times:
Tuesday & Wednesday: 10.00 - 17.00
Thursday: 10.00 - 12.30
Other days (else) is closed.
I've got an image for open (images/open.png & images/open@2x.png
) and one for closed (images/closed.png & images/closed@2x.png
).
I want to display those images as a background image (CSS) in a class (.open-closed) which has the following styles:
.open-closed {
width: 48%;
background-color: #b3b3b3;
display: inline-block;
margin-top: 3%;
border: 5px solid white;
min-height: 300px;
float: left;
}
Yes, it's not very correct since the width is better in pixels since there is an image in it, but I will fine-tune this as soon as the script is done.
I don't know much about jQuery/Javascript, almost nothing. But I googled some pieces together and edited some parts. What am I doing wrong?
<script language="JavaScript">
day=new Date() //..get the date
x=day.getHours() //..get the hour
if(x>=10 && x<17) {
document.write('<style type="text/css">.open-closed{background-image: url(images/open.png); background-repeat:no-repeat; width:300px; height: 285px; background-size: 300px 285px;}</style>')
} else
if (x>=17 && x<24) {
document.write('<style type="text/css">.open-closed{background: url(images/closed.png); background-repeat:no-repeat; width:300px; height: 285px; background-size: 300px 285px;}</style>')
} else
if (day=tuesday && x>=10 && x<12.30) {
document.write('<style type="text/css">.open-closed{background: url(images/open.png); background-repeat:no-repeat; width:300px; height: 285px; background-size: 300px 285px;}</style>')
} else
if (day=monday) {
document.write('<style type="text/css">.open-closed{background: url(images/closed.png); background-repeat:no-repeat; width:300px; height: 285px; background-size: 300px 285px;}</style>')
} else
if (day=friday) {
document.write('<style type="text/css">.open-closed{background: url(images/closed.png); background-repeat:no-repeat; width:300px; height: 285px; background-size: 300px 285px;}</style>')
} else
if (day=saturday) {
document.write('<style type="text/css">.open-closed{background: url(images/closed.png); background-repeat:no-repeat; width:300px; height: 285px; background-size: 300px 285px;}</style>')
} else
if (day=sunday) {
document.write('<style type="text/css">.open-closed{background: url(images/closed.png); background-repeat:no-repeat; width:300px; height: 285px; background-size: 300px 285px;}</style>')
}
</script>
It's probably a very stupid mistake...