[jQuery] New to jQuery: Problem setting current time to some element
Hi,
This is my code:
function displayDate(){
var date = new Date();
$("#dateandtime").text(date);
}
$(document).ready(function(){
setInterval('displayDate()', 1000);
});
But it doesn't work, however, if I have this:
$("#dateandtime").text("some text");
The content of the <span> element with "dateandtime" id selector will
change to "some text". I don't understand why it doesn't change when I
have this:
$("#dateandtime").text(date);
I'm new to jQuery, please advise... Thanks in advance.