• Welcome to the world's largest Chinese hacker forum

    Welcome to the world's largest Chinese hacker forum, our forum registration is open! You can now register for technical communication with us, this is a free and open to the world of the BBS, we founded the purpose for the study of network security, please don't release business of black/grey, or on the BBS posts, to seek help hacker if violations, we will permanently frozen your IP and account, thank you for your cooperation. Hacker attack and defense cracking or network Security

    business please click here: Creation Security  From CNHACKTEAM

Recommended Posts

身体

差异

输入类型='text' class='d1 '

button class=' D2 ' value=' start '/按钮

button class=' D3 ' value=' end '/按钮

/div

脚本

//let start BTN=$(' # D2 ')[0];

let start BTN=document . getelementbyid(' D2 ')

let stopEle=document . getelementbyid(' D3 ')

let input ele=document . getelementbyid(' D1 ')

//4.定义一个专门显示时间的函数

函数showTime(){

//2.获取当前时间对象

让cTimeObj=新日期()

//3.将其添加到输入标记的value属性中

input ele . value=ctime obj . tolocalestring()

}

//6.定义一个全局变量来存储定时器对象(应该使用多个函数)

设timeObj=null

//1.首先将一个点击事件绑定到开始按钮。

startBtn.onclick=function () {

//8.判断变量是否引用了定时器,其实就是判断是否已经有任务了。如果有,就不要再创建了。

如果(!timeObj){

//5.周期计时任务

Timeobj=setinterval (showtime,1000)//如果有多个任务,变量只能指向最后一个。

}

}

//7.将stop按钮与取消计时器的click事件绑定。

stopEle.onclick=function () {

ClearInterval(timeObj) //删除任务不会清空变量的值。

//清空变量的值

timeObj=null

}

/脚本

/body

Link to comment
Share on other sites