The following code is working perfectly fine in all browsers except for safari. safari is showing me this weird nand nanh nanm nans instead of ticking timer.
$( document ).ready(function() {
var specialDate = "<?php echo trim(date('Y-m-d\TH:i:s',strtotime($time[1])));?>";
var countDownDate = new Date(specialDate).getTime();
var x = setInterval(function() {
var now = new Date().getTime();
var distance = countDownDate - now;
var days = Math.floor(distance / (1000 * 60 * 60 * 24));
var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
document.getElementById("buy_<?php echo $key; ?>").innerHTML = days + "d " + hours + "h " + minutes + "m " + seconds + "s ";
}, 1000);
///////////////// Buy Now End//////////////////
});
When I checked the console it show me following error on this line
Uncaught TypeError: Cannot set property 'innerHTML' of null
document.getElementById("buy_<?php echo $key; ?>").innerHTML = days + "d " + hours + "h " + minutes + "m " + seconds + "s ";
P.S Although all browsers except for safari are showing me days hours minutes seconds countdown fine but if I check console in any browser it is also showing me the same above mentioned error. any help here ?