Hello, Would you plz tell me how can get a good jQuery code for making a clock on my website?
There’s a lot of info on the web about this, so best to Google this kind of question first. Here’s the first thing I found on Google:
Why use jquery? It’s only a few lines of code using plain javascript. If you use jquery, you’ll be running a lot more code in the background.
<body>
<div id="clockContainer">
<span id="spHrs"></span> : <span id="spMins"></span> : <span id="spSecs"></span>
</div>
<script type="text/javascript">
function showTime(){
var timeNow = new Date();
document.getElementById('spHrs').innerHTML = timeNow.getHours();
document.getElementById('spMins').innerHTML = timeNow.getMinutes();
document.getElementById('spSecs').innerHTML = timeNow.getSeconds();
}
setInterval(showTime,1000);
</script>
</body>
But in any case, you’'re probably better off using a server side clock because what about if the user’s local clock time is incorrect?