Jump to content

Javascript formatting


BobbyFrankyJim

Recommended Posts

Hmm, you might need to post an example of your code and what you're trying to achieve, exactly.Depending on how you're putting the results in the elements, styling them may require different techniques.

Link to comment
Share on other sites

Here is the code:

<script type="text/javascript">function startTime(){var today=new Date();var h=today.getHours();var m=today.getMinutes();var s=today.getSeconds();// add a zero in front of numbers<10m=checkTime(m);s=checkTime(s);document.getElementById('txt').innerHTML=h+":"+m+":"+s;t=setTimeout('startTime()',500);}function checkTime(i){if (i<10)  {  i="0" + i;  }return i;}</script></head><body onload="startTime()"><div id="txt"></div>

Link to comment
Share on other sites

he means place in where your javascript code is placed between head tags<script type="text/javascript">function startTime(){var today=new Date();var h=today.getHours();var m=today.getMinutes();var s=today.getSeconds();// add a zero in front of numbers<10m=checkTime(m);s=checkTime(s);document.getElementById('txt').innerHTML=h+":"+m+":"+s;t=setTimeout('startTime()',500);}function checkTime(i){if (i<10) { i="0" + i; }return i;}</script><style type="text/css">#txt { text-align: center; }</style></head><body onload="startTime()"><div id="txt"></div>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...