jquery html5 makes a cool disc clock_jquery
A clock watch written in HTML5 jQuery that I packaged myself
Code:
<!DOCTYPE html PUBLIC "-//W3C//h2D XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/h2D/xhtml1-transitional.h2d"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>超酷数码钟表</title> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs /jquery/1.10.2/jquery.min.js"></script> <script type="text/javascript"> //引用的是在线jquery地址,如果不行请自行下载切换 (function($){ $.fn.drawClock = function(options){ var mainId = $(this); //设置默认参数 var defaultOptions = { 'width': '300px', 'height': '300px', 'margin': '200px auto', 'border': '1px solid #888', 'border-radius': '50%', 'box-shadow': '2px 2px 4px #111' }; var options = $.extend(defaultOptions, options); mainId.css({ 'width': options.width, 'height': options.height, 'margin': options.margin, 'border': options.border, 'border-radius': options['border-radius'], 'box-shadow': options['box-shadow'], 'position': 'relative' }).css({ 'background': '-webkit-gradient(radial, ' + mainId.width()/2 + ' ' + mainId.height()/2 + ', 0, ' + mainId.width()/2 + ' ' + mainId.height()/2 + ', ' + mainId.width()/2 + ', from(#ffe), to(#eee))', 'background': '-moz-radial-gradient(circle closest-side, #ffe 0%, #eee 100%)' }); //钟表盘中心圆 $("<div id='circle'></div>").appendTo(mainId).css({ 'width': '20px', 'height': '20px', 'border-radius': '50%', 'box-shadow': '0 0 5px rgba(0,0,0,0.8)', 'position': 'absolute', 'z-index': 999, 'background': '-webkit-gradient(radial, ' + mainId.width()/2 + ' ' + mainId.height()/2 + ', 0, ' + mainId.width()/2 + ' ' + mainId.height()/2 + ', ' + mainId.width()/2 + ', from(#ffe), to(#eee))', 'background': '-moz-radial-gradient(circle, #eee 30%, #ffe 100%)' }).css({ 'left': mainId.width()/2 - $('#circle').width()/2, 'top': mainId.height()/2 - $('#circle').height()/2 }); var dateTime = new Date(); var oHours = dateTime.getHours(); var oMinutes = dateTime.getMinutes(); var oSeconds = dateTime.getSeconds(); //初始化时分秒 var hPointer = drawPointer(mainId.width()/2, mainId.height()/2, mainId.width()/2*(3/6), 5, "#333", -90+oHours*30+oMinutes*6/12); var mPointer = drawPointer(mainId.width()/2, mainId.height()/2, mainId.width()/2*(4/6), 4, "#666", -90+oMinutes*6); var sPointer = drawPointer(mainId.width()/2, mainId.height()/2, mainId.width()/2*(5/6), 3, "#f00", -90+oSeconds*6); //运动时分秒 var timer = setInterval(function(){ dateTime = new Date(); oHours = dateTime.getHours(); oMinutes = dateTime.getMinutes(); oSeconds = dateTime.getSeconds(); hPointer.css({'transform': 'rotate(' + (-90+oHours*30+oMinutes*6/12) + 'deg)'}); mPointer.css({'transform': 'rotate(' + (-90+oMinutes*6) + 'deg)'}); sPointer.css({'transform': 'rotate(' + (-90+oSeconds*6) + 'deg)'}); }, 1000); //绘制钟表刻度 for(var i=0; i<60; i++){ var width = 3, height = 6, oBcolor = '#111'; if(i%5 == 0){ width = 5; height = 10; } if(i%15 == 0){ oBcolor = 'red'; } $("<div class='clockMark'></div>").appendTo(mainId).css({ 'width': width, 'height': height, 'position': 'absolute', 'top': 0, 'left': mainId.width()/2, 'background': oBcolor, 'transform': 'rotate(' + i*6 + 'deg)', "transform-origin": "0 " + mainId.width()/2+'px' }); } //绘制钟表指针 function drawPointer (startx, starty, width, height, bcolor, angle) { var oPointer = $("<div></div>"); oPointer.appendTo(mainId).css({ 'width': width, 'height': height, 'position': 'absolute', 'top': starty, 'left': startx, 'background': bcolor, 'transform': 'rotate(' + angle + 'deg)', 'transform-origin': '0 0' }); return oPointer; } return this; } })(jQuery); </script> <script type="text/javascript"> $(function(){ $('#clock').drawClock(); }); </script> </head> <body> <div id="clock"></div> </body> </html>
Demo picture:
The above is the entire content of this article, I hope you all like it.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Is the clock app missing from your phone? The date and time will still appear on your iPhone's status bar. However, without the Clock app, you won’t be able to use world clock, stopwatch, alarm clock, and many other features. Therefore, fixing missing clock app should be at the top of your to-do list. These solutions can help you resolve this issue. Fix 1 – Place the Clock App If you mistakenly removed the Clock app from your home screen, you can put the Clock app back in its place. Step 1 – Unlock your iPhone and start swiping to the left until you reach the App Library page. Step 2 – Next, search for “clock” in the search box. Step 3 – When you see “Clock” below in the search results, press and hold it and

Detailed explanation of jQuery reference method: Quick start guide jQuery is a popular JavaScript library that is widely used in website development. It simplifies JavaScript programming and provides developers with rich functions and features. This article will introduce jQuery's reference method in detail and provide specific code examples to help readers get started quickly. Introducing jQuery First, we need to introduce the jQuery library into the HTML file. It can be introduced through a CDN link or downloaded

How to use PUT request method in jQuery? In jQuery, the method of sending a PUT request is similar to sending other types of requests, but you need to pay attention to some details and parameter settings. PUT requests are typically used to update resources, such as updating data in a database or updating files on the server. The following is a specific code example using the PUT request method in jQuery. First, make sure you include the jQuery library file, then you can send a PUT request via: $.ajax({u

How to remove the height attribute of an element with jQuery? In front-end development, we often encounter the need to manipulate the height attributes of elements. Sometimes, we may need to dynamically change the height of an element, and sometimes we need to remove the height attribute of an element. This article will introduce how to use jQuery to remove the height attribute of an element and provide specific code examples. Before using jQuery to operate the height attribute, we first need to understand the height attribute in CSS. The height attribute is used to set the height of an element

Title: jQuery Tips: Quickly modify the text of all a tags on the page In web development, we often need to modify and operate elements on the page. When using jQuery, sometimes you need to modify the text content of all a tags in the page at once, which can save time and energy. The following will introduce how to use jQuery to quickly modify the text of all a tags on the page, and give specific code examples. First, we need to introduce the jQuery library file and ensure that the following code is introduced into the page: <

Title: Use jQuery to modify the text content of all a tags. jQuery is a popular JavaScript library that is widely used to handle DOM operations. In web development, we often encounter the need to modify the text content of the link tag (a tag) on the page. This article will explain how to use jQuery to achieve this goal, and provide specific code examples. First, we need to introduce the jQuery library into the page. Add the following code in the HTML file:

1. First click on the Start menu and select the Settings button in the Start menu. 2. After opening, select time and language settings. 3. Change it to automatically set the time. 4. You can also turn off the automatic time setting and choose the time you want to change. Method 2: 1. Open the [Other Date, Time and Regional Settings] option. 2. Select [Set time and date]. 3. Select [Internet Time] and open [Change Settings Options]. 4. Check [Synchronize with Internet Time Server (S)], click [Update Now], and then click OK.

How to tell if a jQuery element has a specific attribute? When using jQuery to operate DOM elements, you often encounter situations where you need to determine whether an element has a specific attribute. In this case, we can easily implement this function with the help of the methods provided by jQuery. The following will introduce two commonly used methods to determine whether a jQuery element has specific attributes, and attach specific code examples. Method 1: Use the attr() method and typeof operator // to determine whether the element has a specific attribute
