javascript_DOM事件模型_ZHOU125disorder_

DOM事件模型

  1. 内联模型/事件属性模型,在标签里面绑定事件
<body>
    <div onclick="FUNC()"></div>
    <script>
        function FUNC(){
    
    
            alert("我是要成为火影的男人!!!");
        }
    </script>
</body>

获取的style是从标签内部获取的_也就是从内联样式里面获取的;

  1. 动态绑定/动态事件分配

DOM允许JavaScript向咱们的html元素分配事件,首先是获取元素,然后向元素分配事件

定时器

  • setInterval(产生定时器);

setInterval(function(){},时间);
在给定的时间段,反复执行内部的代码;

    <script>
        setInterval(function(){
    
    
            document.write("卡卡西"+"<br />");
        },1000);//此处的1000是以毫秒为单位_1000毫秒=1秒;
    </script>
  • clearInterval(清除定时器)
	var i=4;
	var time=setInterval(function(){
    
    
			document.write("卡卡西"+"<br />");
		i--;
		if(i==1){
    
    
			clearInterval(time);
	}
},500);

猜你喜欢

转载自blog.csdn.net/ZHOU125disorder/article/details/112261328
今日推荐