SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: live clock

  1. #1
    Non-Member
    Join Date
    Nov 2010
    Posts
    220
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    live clock

    Hello
    How can store this code in a file js and call div#id?
    I dont want call this code with input#id. I want call this code with div#id.
    What is your suggestion?

    Code JavaScript:
    <script type="text/javascript">
                var int=self.setInterval("clock()",1000);
                function clock()
                {
                var d=new Date();
                var t=d.toLocaleTimeString();
                document.getElementById("clock").value=t;
                }
            </script>

  2. #2
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,803
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Use innerHTML instead of value.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  3. #3
    Non-Member
    Join Date
    Nov 2010
    Posts
    220
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you, worked
    How do I set in the file js and call with div#id?
    How is make live clock in jQuery?

  4. #4
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,696
    Mentioned
    101 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by binboy View Post
    How is make live clock in jQuery?
    The web page would only show the time of the computer that it is running on.

    If you want to instead show the accurate time of a certain location, sites like timeanddate.com provide free clocks for your web site
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •