Try this: function displayDate(){ var date = new Date(); $("#dateandtime").text(date.toString()); }
On Aug 1, 5:56 pm, Nazgulled <[EMAIL PROTECTED]> wrote: > 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.