函数,定时器,封装,

函数:

//具名函数
    function aaa(){
        console.log('具名函数1')
    }
    aaa()
    //匿名函数
    var bbb=function(){
        console.log('匿名函数2')    
    }
    bbb()
    //匿名函数自调用
    !function(){
        console.log('自调用函数函数3')
    }
    ()

定时器:

setInterval(function(){
            console.log(new Date)
        },1000)
//1000毫秒执行一次

对函数的封装:(在两个不同地方设置函数调用函数)

设置函数

function crash(obj1,obj2) {
if (
) return false
 
}
调用函数:
crash()

不封装的函数:

crashTimer = setInterval(function () {
function crash(obj1,obj2) {
if (.........
) {crash()}
else{
...
}
 
},30)
 
}

js获取html中标签:

const start=document.getElementById('start')

取消时间冒泡:

let ev=event||window.event//event是否存在,如果存在,则ev=event,如果event不存在,en=window.event

if (ev.stopPropagation()){

event.stopPropagation()//取消事件冒泡

}else{

event.cancelBubble=true//取消事件冒泡

}

在js中规定css样式

div1.innerHTML=` .........    `

在js中引用音乐:

audios[0].pause()//关闭音乐
audios[1].play()//使用音乐
 

 

posted @ 2021-12-07 15:13  又等花开风起  阅读(45)  评论(0)    收藏  举报