時鐘Jquery+html5特效代碼分享(可設定鬧鐘並且語音提醒)_jquery

來源:互聯網
上載者:User

本文執行個體講述了Jquery+html5可設定鬧鐘並且會語音提醒的時鐘特效。分享給大家供大家參考。具體如下:
這是一款基於Jquery+html5實現可設定鬧鐘並且會語音提醒的時鐘特效代碼,超逼真的類比時鐘,最大的特點還可以語音提醒,感興趣的小夥伴們快來研究研究。
運行效果圖:-------------------查看效果 下載源碼-------------------

小提示:瀏覽器中如果不能正常運行,可以嘗試切換瀏覽模式。
為大家分享的Jquery+html5實現可設定鬧鐘並且會語音提醒的時鐘特效代碼如下

<!doctype html><html lang="zh"><head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">  <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>HTML5 canvas超逼真的類比時鐘特效</title> <link rel="stylesheet" type="text/css" href="css/normalize.css" /> <link rel="stylesheet" type="text/css" href="css/default.css"> <link href='http://fonts.useso.com/css?family=PT+Sans' rel='stylesheet' type='text/css'> <link rel="stylesheet" media="screen" href="css/main.css"/> <!--[if IE]> <script src="http://libs.useso.com/js/html5shiv/3.7/html5shiv.min.js"></script> <![endif]--></head><body> <div class="htmleaf-container">  <div class="container"> <div id="myclock"></div> <div id="alarm1" class="alarm"><a href="javascript:void(0)" id="turnOffAlarm">關閉鬧鐘</a></div> </div> <br/><br/> <input type="text" id="altime" placeholder="hh:mm"/><br><br> <a href="javascript:void(0)" id="set">設定鬧鐘</a>  </div>  <script src="http://libs.useso.com/js/jquery/2.1.1/jquery.min.js" type="text/javascript"></script> <script>window.jQuery || document.write('<script src="js/jquery-2.1.1.min.js"><\/script>')</script> <script language="javascript" type="text/javascript" src="js/jquery.thooClock.js"></script>  <script language="javascript"> var intVal, myclock; $(window).resize(function(){ window.location.reload() }); $(document).ready(function(){ var audioElement = new Audio(""); //clock plugin constructor $('#myclock').thooClock({ size:$(document).height()/1.4, onAlarm:function(){ //all that happens onAlarm $('#alarm1').show(); alarmBackground(0); //audio element just for alarm sound document.body.appendChild(audioElement); var canPlayType = audioElement.canPlayType("audio/ogg"); if(canPlayType.match(/maybe|probably/i)) { audioElement.src = 'alarm.ogg'; } else { audioElement.src = 'alarm.mp3'; } // erst abspielen wenn genug vom mp3 geladen wurde audioElement.addEventListener('canplay', function() { audioElement.loop = true; audioElement.play(); }, false); }, showNumerals:true, brandText:'THOOYORK', brandText2:'Germany', onEverySecond:function(){ //callback that should be fired every second }, //alarmTime:'15:10', offAlarm:function(){ $('#alarm1').hide(); audioElement.pause(); clearTimeout(intVal); $('body').css('background-color','#FCFCFC'); } }); });  $('#turnOffAlarm').click(function(){ $.fn.thooClock.clearAlarm(); }); $('#set').click(function(){ var inp = $('#altime').val(); $.fn.thooClock.setAlarm(inp); });  function alarmBackground(y){ var color; if(y===1){ color = '#CC0000'; y=0; } else{ color = '#FCFCFC'; y+=1; } $('body').css('background-color',color); intVal = setTimeout(function(){alarmBackground(y);},100); } </script></body></html>

以上就是為大家分享的jQuery超逼真的時鐘特效,希望大家可以喜歡。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.