<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
? ? <style type="text/css">
? ? ? ? .mytable
? ? ? ? {
width:300px;
? ? ? ? }
.mytable td{height:100px;border:1px solid #aaccff;text-align:center;}
.mytable td label{font-size:60px;font-weight:bold;color:Red;}
.box{border:1px solid #aaccff;padding:10px;margin:5px 3px;line-height:25px;}
? ? <script src="jquery-1.12.4.js">
? ? ? ? $(function () {
window.setInterval(fun, 300);
? ? ? ? });
? ? ? ? function fun() {
$("#table1 label")
//監(jiān)聽事件:獲取label的值集合
? ? ? ? ? ? ? ? .map(function (value, index) {
//獲取到單個(gè)label的文本值
? ? ? ? ? ? ? ? var $txt =$(index).text();
? ? ? ? ? ? ? ? //將其轉(zhuǎn)換為int型
? ? ? ? ? ? ? ? ? ? $txt =parseInt($txt);
? ? ? ? ? ? ? ? if ($txt ==8) {
//給當(dāng)前l(fā)abel賦值
? ? ? ? ? ? ? ? ? ? $(index).text("1");
? ? ? ? ? ? ? ? }
else {
//給當(dāng)前l(fā)abel賦值
? ? ? ? ? ? ? ? ? ? $(index).text($txt +1);
? ? ? ? ? ? ? ? }
});
? ? ? ? }
<body style="font-size:12px;">
? ? <div class="box">
? ? ? ? 請(qǐng)編寫javascript代碼,完成如下功能要求:
? ? ? ? 1.每隔300毫秒,讓所有的數(shù)字逆時(shí)針旋轉(zhuǎn)
? ? <div class="box">
? ? ? ? <table id="table1" class="mytable">
? ? ? ? ? ? ? ? ? ? <label id="Label1">1
? ? ? ? ? ? ? ? ? ? <label id="Label2">2
? ? ? ? ? ? ? ? ? ? <label id="Label3">3
? ? ? ? ? ? ? ? ? ? <label id="Label8">8
? ? ? ? ? ? ? ? ? ? <label id="Label4">4
? ? ? ? ? ? ? ? ? ? <label id="Label7">7
? ? ? ? ? ? ? ? ? ? <label id="Label6">6
? ? ? ? ? ? ? ? ? ? <label id="Label5">5