date()。getHours / minutes/Secondsに接続する時計を作成しました。表示されている画像はさまざまなクラスに埋め込まれています。
今、私が画像を変更したいとき、私は毎秒分と時間ごとにスイッチを書きました..それはおそらくグーグルエンジンよりも多くのコードです。だからもっと簡単な解決策があるのだろうか。
これは時間スイッチのコードであるため、15分が時計に到達すると、classNameを1と5に変更します。
switch(h){
case 15:
x = hours.appendChild(hour1).className = "clock-digit-one";
x = hours.appendChild(hour2).className = "clock-digit-five";
break
case 16:
x = hours.appendChild(hour1).className = "clock-digit-one";
x = hours.appendChild(hour2).className = "clock-digit-six";
break
default:
x = hours.appendChild(hour1).className = "clock-digit-zero";
x = hours.appendChild(hour2).className = "clock-digit-zero";
}
より多くのコードを表示するjsFiddleを作成しました。どんなヒントも素晴らしいでしょう。 http://jsfiddle.net/Xk49c/2/
ありがとう