Blogger Information
Blog 15
fans 0
comment 0
visits 10429
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
网页中调用JS的三种方法-2019年1月17日
超超的博客
Original
862 people have browsed it

<!DOCTYPE >

<html>

<meta charset="utf-8">

<title>js引入方式</title>

<head>

<style>

#ball{

width:100px;

height:80px;

padding-top:20px;

border-radius:50%;

background-color:red;

position:relative;

font-size:12px;

}

</style>

</head>

<body>

<h1 onclick="alert('我要成为全栈工程师')">方法一,在元素事件方法属性上是写入js</h1>

<div id="ball" onclick="running()">方法二,在script中写入js</div>

<script>

var ball = document.getElementById('ball');

function running(){

var count = 0;  

var timer = setInterval(function (){

if (count < 100) {

ball.style.width = ball.style.height = ball.style.top = ball.style.left = count + "px";

count++;

} else { 

clearInterval(timer);

}

}, 100);

}

</script>

/*方法三外部引入js文件*/

<script src="ball.js"></script>

</body>

</html>


Correction status:qualified

Teacher's comments:下次记得给代码加上语言标记 而且总结也需要写的
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments