<a class="banner-new" href="/order" style="display: none;"><img src="http://sait/images/img2.png" alt="discount" /></a> <br />
<a class="newdiscount" title="Discount banner" href="http://sait/order"><img alt="Discount banner" src="/images/img1.gif" /></a>
<script>
function banners (bannerIn, bannerOut, dateIn, dateOut) {
var currentDate = new Date();
this.bannerIn = bannerIn;
this.bannerOut = bannerOut;
this.dateIn = dateIn;
this.dateOut = dateOut;
//date reading by js
dateInReady = new Date(dateIn);
dateOutReady = new Date(dateOut);
if (currentDate < dateOutReady) {
if (currentDate > dateInReady) {
document.querySelector(bannerIn).style.display = "block";
document.querySelector(bannerOut).style.display = "none";
console.log('the temporary banner is loaded');
} else { console.log("the temporary banner not loaded") }
} else { console.log("the temporary banner not loaded") }
}
document.addEventListener('DOMContentLoaded', function() {
banners (".banner-new",".newdiscount","November 29, 2013 00:01","December 05, 2013 00:00")
})
</script>
Вообщем подгружает сначала старую картинку, а потом новую! а мне нужно чтобы сразу менял картинки!