欧美大屁股bbbbxxxx,狼人大香伊蕉国产www亚洲,男ji大巴进入女人的视频小说,男人把ji大巴放进女人免费视频,免费情侣作爱视频

歡迎來到入門教程網(wǎng)!

JavaScript

當(dāng)前位置:主頁 > 網(wǎng)絡(luò)編程 > JavaScript >

javascript實(shí)現(xiàn)點(diǎn)擊星星小游戲

來源:本站原創(chuàng)|時(shí)間:2020-01-10|欄目:JavaScript|點(diǎn)擊: 次

本文實(shí)例為大家分享了JavaScript實(shí)現(xiàn)點(diǎn)擊星星的具體代碼,供大家參考,具體內(nèi)容如下

<head>
 <meta charset="UTF-8">
 <title>Document</title>
 <style type="text/css">
 #d2{
 width:100px;
 height:20px;
 border:1px solid red;
 display:inline-block;
 }
 #d3{
 display:inline-block;
 background:yellow;
 height:20px;
 }
 </style>
 <script type="text/javascript">
 <!--
 var dingshiqi; //定時(shí)器
 var count=0; //記錄星星的個(gè)數(shù)
 var n=0; //記錄游戲時(shí)間的變量。
 var sj; //時(shí)間定時(shí)器(解決一直按開始游戲bug)
 function StarGame(){ //開始游戲
 window.clearInterval(sj); //清除時(shí)間定時(shí)器
 window.clearInterval(dingshiqi);//清楚定時(shí)器
 dingshiqi=window.setInterval("star()",400);
 sj=window.setInterval("shijian()",1000);
 }
 //創(chuàng)建星星
 function star(){
 var obj=document.createElement("img");
 //給星星添加src屬性
 obj.src="image.png"
 //隨機(jī)星星大小
 var w=Math.floor(Math.random()*80+20);
 obj.width=w;
 obj.height=w;
 //隨機(jī)位置
 var x=Math.floor(Math.random()*1166+100);
 var y=Math.floor(Math.random()*500+100);
 obj.style.position="absolute";
 obj.style.top=y+"px";
 obj.style.left=x+"px";
 //放到body中
 document.body.appendChild(obj);
 //添加onclick點(diǎn)擊事件(綁定的onclick 不需要加";")
 obj.οnclick=removeStar;
 //控制大于20個(gè)星星游戲結(jié)束
 count++;
 var sp=document.getElementById("d3");
 sp.style.width=count*5+"px";
 if(count>20){
 alert("大于20個(gè)星星游戲結(jié)束");
 window.clearInterval(dingshiqi);
 location.reload(); //重新加載
 }
 //放到body中
 document.body.appendChild(obj);
 }
 //點(diǎn)擊刪除星星
 function removeStar(){
 this.parentNode.removeChild(this);
 count--; //點(diǎn)擊星星刪除,都要count-1.
 var sp=document.getElementById("d3");
 sp.style.width=count*5+"px";
 }
 //點(diǎn)擊暫停游戲。
 function zanting(){
 alert("暫停游戲");
 }
 //記錄游戲時(shí)間的函數(shù)
 function shijian(){
 n++;
 var obj=document.getElementById("d1");
 obj.innerHTML="游戲進(jìn)行了"+n+"秒"
 }
 //-->
 </script>
 </head>
 <body>
 <input type="button" value="開始游戲" οnclick="StarGame()">
 <input type="button" value="暫停游戲" οnclick="zanting()">
 <span id="d1">游戲進(jìn)行了0秒</span>
 <span id="d2"><span id="d3"></span></span>
 </body>
</html>

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持我們。

上一篇:java遇到微信小程序 &quot;支付驗(yàn)證簽名失敗&quot; 問題解決

欄    目:JavaScript

下一篇:vue實(shí)現(xiàn)移動(dòng)端圖片上傳功能

本文標(biāo)題:javascript實(shí)現(xiàn)點(diǎn)擊星星小游戲

本文地址:http://mengdiqiu.com.cn/a1/JavaScript/9416.html

網(wǎng)頁制作CMS教程網(wǎng)絡(luò)編程軟件編程腳本語言數(shù)據(jù)庫服務(wù)器

如果侵犯了您的權(quán)利,請(qǐng)與我們聯(lián)系,我們將在24小時(shí)內(nèi)進(jìn)行處理、任何非本站因素導(dǎo)致的法律后果,本站均不負(fù)任何責(zé)任。

聯(lián)系QQ:835971066 | 郵箱:835971066#qq.com(#換成@)

Copyright © 2002-2020 腳本教程網(wǎng) 版權(quán)所有