九九乘法表
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>九九乘法口诀表</title>
<style type="text/css">
table{
border-collapse: collapse;
}
tr:nth-of-type(2n+1){
background: #F5F5F5;
}
td{
border: 1px solid orange;
padding: 5px;
}
</style>
</head>
<body>
<h1>九九乘法表</h1>
<script type="text/javascript">
let str="<table>";
for (let i=1;i<10;i++) {
str+="<tr>";
for (let j=1;j<=i;j++) {
str+="<td>"+j+"X"+i+"="+j*i+"</td>";
}
str+="</tr>";
}
str+="</table>";
document.write(str);
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
</body>
<script type="text/javascript">
let questions=new Array();
let questionXz=new Array();
let answers=new Array();
questions[0]="下列选项中( )可以用来检索下列列表中被选项的索引号。";
questionXz[0]=["selectedIndex","options","length","len"];
answers[0]="A";
questions[1]="下列选项中( )可以用来检索下列列表中被选项的索引号。";
questionXz[1]=["selectedIndex","options","length","len"];
answers[1]="C";
let str="";
for (let i=0;i<questions.length;i++) {
str+=(i+1)+"."+questions[i]+"<br />";
for(let j=0;j<questionXz[i].length;j++){
str+=String.fromCharCode(j+65)+"、 "+questionXz[i][j]+"<br />";
}
str+="答案是:"+answers[i]+"<br />";
}
document.write(str);
</script>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>随机点名</title>
<style>
#content{
width: 600px;
height: 400px;
background: #000;
margin: 100px auto;
text-align: center;
position: relative;
line-height: 300px;
color: dodgerblue;
font-size: 70px;
}
#btn1{
background: #ccc;
width: 180px;
height: 80px;
font-size: 30px;
color: #f40;
border-radius: 12px;
position: absolute;
bottom: 30px;
left: 50%;
margin-left: -90px;
}
</style>
</head>
<body>
<div id="content">
<span id="span1">
点击开始
</span>
<button id="btn1">
start
</button>
</div>
<script>
var arr = ["崔雪莉","郭雪芙","嘉歆","阿芳","雪灵","老王","刘疙瘩","许大妈","韩晁","静涵","允儿","查灿灿","靓影","杨幂","李静","邓超","李伟","蓝老师","金枝","静恬","允儿","杨幂","晶灵","林志玲","嘉懿","流行","邓超","郭琦","允儿","许大妈","林妹妹","杨幂","佳思","吉玉","张焕","张赛","师傅","菊月","王晶","吉玟","王飞","林志玲","曾艳","王翠青","JaydenLD"];
var $btn1 = document.getElementById('btn1');
var $content = document.getElementById('content');
var $span1 = document.getElementById('span1');
var timer;//计时器
var testNum = true;
$btn1.onclick = function(){
if(testNum){
// console.log(1);
start();
$btn1.innerHTML = 'stop';
testNum = false;
}
else{
// console.log(0);
stop();
$btn1.innerHTML = 'start';
testNum = true;
}
}
function start(){
timer = setInterval(function(){
var num = random(0,arr.length - 1);
$span1.innerHTML = arr[num];
},50)
}
function stop(){
clearInterval(timer);
}
// 随机函数
function random(a,b){
var randomNum = Math.round(Math.random() * (b - a) + a);
return randomNum;
}
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
div{
width: 600px;height: 300px;margin: 50px auto;background: #708090;
border: 2px #66CDAA dashed;border-radius: 15px;
color: #fff;font-size: 45px;line-height: 100px;
}
p{margin: 50px 20px;}
#start{text-align: center;background: #87CEFA;display: block;border-radius: 10px;width: 150px;
margin: 40px auto;line-height: 55px;font-size: 30px;}
</style>
</head>
<body>
<div id="box">
<p>中奖号码:<span id="p1"></span></p>
<button type="button" id="start" onclick="start()">开始抽奖</button>
</div>
<script type="text/javascript">
function add(){
let n=Math.ceil(Math.random()*11);
if(n<10){
n="0"+n;
}
return n;
}
function sortNum(a,b){
return a-b;
}
function start(){
let nums=[];
let num;
for (let i=0;nums.length<5;i++) {//此处应该判断数组的长度而不是i的值
num=add();
if(nums.indexOf(num)<0){//判断能否在数组中找到该数值
nums.push(num);
}
}
let p1=document.getElementById("p1");
p1.innerHTML=(nums.sort(sortNum)).join(" ");//对数字排序必须使用该函数
}
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<form action="" name="myForm">
<p>你喜欢做的事情:</p>
<p><input type="checkbox" name="bobby" id="ball"/><label for="ball">打球</label></p>
<p><input type="checkbox" name="bobby" id="tv"/><label for="tv">看电视</label></p>
<p><input type="checkbox" name="bobby" id="net"/><label for="net">上网</label></p>
<p><input type="checkbox" name="bobby" id="book"/><label for="book">看书</label></p>
<p><input type="checkbox" name="bobby" id="travl"/><label for="travl">旅游</label></p>
<button type="button" onclick="changeBoxes(1)">全选</button>
<button type="button" onclick="changeBoxes(0)">全不选</button>
<button type="button" onclick="changeBoxes(-1)">反选</button>
</form>
<script type="text/javascript">
function changeBoxes(a){
let oForm=document.myForm;
let oCheckBox=oForm.bobby;
for(let i=0;i<oCheckBox.length;i++){
if(a<0){
oCheckBox[i].checked=!oCheckBox[i].checked;
}else{
oCheckBox[i].checked=a;
}
}
}
</script>
</body>
</html>