===第一题===
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script src="js/jquery-1.12.4.js" type="text/javascript"></script>
</head>
<body>
原字符串:<input id="yuan" /><br />
需要查找的字符串:<input id="zifu" /><br />
<button id="chazhao">查找</button>
<script type="text/javascript">
//第一种
$("#chazhao").click(function(){
var old=$("#yuan").val();
var cha=$("#zifu").val();
var a=(old.split(cha)).length-1;
if (a>0) {
alert(old+"中"+cha+"出现了"+a+"次")
}else{
alert(old+"中没有出现"+cha)
}
})
//第二种
// $("#chazhao").click(function(){
// var old=$("#yuan").val();
// var cha=$("#zifu").val();
// var a=(old.split(""));
// var b=0;
// for (var i = 0; i < a.length; i++) {
// if (cha==a[i]) {
// b+=1
// }
// }
// alert(old+"中"+cha+"出现了"+b+"次")
// })
</script>
</body>
</html>
===第二题===
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script src="js/jquery-1.12.4.js" type="text/javascript"></script>
</head>
<body>
请输入一个数字:<input id="shuru" /><br />
<button id="tj">添加</button>
<script type="text/javascript">
$("#tj").click(function(){
var num=[99,85,82,63,60];
var shuru=$("#shuru").val();
var shuru1=parseInt(shuru);
var num1=num.push(shuru1);
if (isNaN(shuru)) {
alert("你输入的数字有问题")
}else{
num.sort(function(x,y){
return y-x
})
}
console.log(num)
})
</script>
</body>
</html>
===第三题===
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script src="js/jquery-1.12.4.js" type="text/javascript"></script>
</head>
<body>
<input type="checkbox" id="ft" name="gua" οnclick="dg()" />飞天<br />
<input type="checkbox" id="dd" name="gua" οnclick="dg()"/>遁地<br />
<input type="checkbox" id="zm" name="gua" οnclick="dg()"/>自瞄<br />
<input type="checkbox" id="ts" name="gua" οnclick="dg()"/>透视<br />
<input type="checkbox" id="qx" name="quan" οnclick="quanXuan()" />全选<br />
<script type="text/javascript">
var gua1=document.getElementById("ft");
var gua2=document.getElementById("dd");
var gua3=document.getElementById("zm");
var gua4=document.getElementById("ts");
var quanx=document.getElementById("qx");
function dg(){
var gua=gua1.checked&&gua2.checked&&gua3.checked&&gua4.checked
if (gua==true) {
quanx.checked=true
}else{
quanx.checked=false
}
}
var zong=document.getElementsByName("gua");
function quanXuan(){
for (var i = 0; i < zong.length; i++) {
zong[i].checked=quanx.checked
}
}
</script>
</body>
</html>
===第四题===
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script src="js/jquery-1.12.4.js" type="text/javascript"></script>
</head>
<body>
<div id="div">
<a href="http://www.baidu.com" target="_blank">
<img id="ig" src="img/ig.jpg" width="200px" height="200px" />
</a>
</div>
<script type="text/javascript">
$(function() {
$("#ig").mouseover(function() {
$(this).css("width", "300px");
$(this).css("height", "300px");
});
$("#ig").mouseleave(function() {
$(this).css("width", "200px");
$(this).css("height", "200px");
})
})
</script>
</body>
</html>
===第五题===
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script src="js/jquery-1.12.4.js" type="text/javascript"></script>
</head>
<body>
行:<input id="hang" /><br />
列:<input id="lie" /><br />
<button id="anniu">创建表格</button>
<div id="bg">
</div>
<script type="text/javascript">
$("#anniu").click(function(){
var hang=$("#hang").val();
var lie=$("#lie").val();
var table=$("<table height='500px' width='500px' border='1px' bgcolor='azure' cellpadding='0px' cellspacing='0px'></table>");
for (var i = 0; i < hang; i++) {
var tr=$("<tr></tr>");
$(table).append(tr)
for (var j = 0; j < lie; j++) {
var td=$("<td></td>");
$(tr).append(td)
}
}
$("#bg").append(table)
})
</script>
</body>
</html>
===第六题===
首页
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script src="js/jquery-1.12.4.js" type="text/javascript"></script>
</head>
<body>
<button id="zhuce" οnclick="zhuCe()">注册</button>
<button id="denglu" οnclick="dengLu()">登录</button>
<script type="text/javascript">
function zhuCe(){
window.open("zhuce1.html")
}
function dengLu(){
window.open("denglu1.html")
}
</script>
</body>
</html>
注册
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script src="js/jquery-1.12.4.js" type="text/javascript"></script>
</head>
<body>
注册用户:<input id="yh" name="users" placeholder="长度在6-15之间"/><br />
填写密码:<input id="mm" name="pwd" type="password" placeholder="长度在6-15之间"/><br />
验证密码:<input id="ymm" name="ypwd" type="password" placeholder="长度在6-15之间"/><br />
<button type="submit" id="btn" οnclick="zhuCe()">注册</button>
<script type="text/javascript">
function zhuCe(){
var unames=["zhangsan","wangwu"];
var pwords=["123123","111111"];
var yh=document.getElementById("yh").value;
var mm=document.getElementById("mm").value;
var ymm=document.getElementById("ymm").value;
var len1=(yh.length>=6)&&(yh.length<=15);
var len2=(mm.length>=6)&&(mm.length<=15);
var a=0;
for (var i = 0; i < unames.length; i++) {
if (yh==unames[i]) {
alert("用户名已存在")
a=-1
}
}
if (a==0) {
if (len1==true) {
if (len2==true) {
if (mm==ymm) {
var num=Math.random()*10+"";
var yan=num.substring(2,6);
console.log(yan)
var shu=prompt("请输入4位验证码")
if (shu==yan) {
alert("恭喜注册成功")
unames.push(yh)
pwords.push(mm)
window.open("denglu1.html?"+unames+"&"+pwords)
}else{
alert("验证码有问题")
}
}else{
alert("第二次密码输入错误")
}
}else{
alert("密码长度不对")
}
}else{
alert("用户名长度不对")
}
}
}
</script>
</body>
</html>
登录
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script src="js/jquery-1.12.4.js" type="text/javascript"></script>
</head>
<body>
填写用户:<input id="yh" name="users" placeholder="长度在6-15之间"/><br />
填写密码:<input id="mm" name="pwd" type="password" placeholder="长度在6-15之间"/><br />
<button type="submit" id="btn" οnclick="dengLu()">登录</button>
<script type="text/javascript">
console.log(location.search)
var a=location.search.substring(1);
var b=a.split("&");
console.log(b)
var a1=b[0];
var a11=a1.split(",");
var a2=b[1];
var a22=a2.split(",");
console.log(a11)
console.log(a22)
function dengLu(){
var yh=document.getElementById("yh").value;
var mm=document.getElementById("mm").value;
var c=-1;
for (var i = 0; i < a1.length; i++) {
if (a11[i]==yh) {
c=i
}
}
console.log(c)
if (c==-1) {
alert("用户不存在")
}else{
if (a22[c]==mm) {
var num=Math.random()*10+"";
var yan=num.substring(2,6);
alert("验证码是:"+yan)
var shu=prompt("请输入4位验证码")
if (shu==yan) {
alert("登录成功")
window.open("yemian.html?"+a11+"&"+a22+"&"+c)
}else{
alert("验证码错误")
}
}else{
alert("密码错误")
}
}
}
</script>
</body>
</html>
页面
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
输入原密码:<input id="ymm" /><br />
请修改密码:<input id="xmm" /><br />
<button id="xiugai" οnclick="xiuGai()">修改</button>
<button id="chaka" οnclick="chaKan()">查看所有用户名和密码</button>
<script type="text/javascript">
// console.log(location.search)
var a=location.search.substring(1);
var b=a.split("&");
// console.log(b)
var a1=b[0];
var a11=a1.split(",");
var a2=b[1];
var a22=a2.split(",");
var a3=b[2];
// console.log(a11)
// console.log(a22)
alert("欢迎你:"+a11[a3])
function chaKan(){
console.log("所有用户名:"+a11)
console.log("所有密码:"+a22)
}
function xiuGai(){
var old1=document.getElementById("ymm").value;
var new1=document.getElementById("xmm").value;
// var x=-1;
if (old1==a22[a3]) {
if (old1!=new1) {
var len2=(new1.length>=6)&&(new1.length<=15)
if (len2==true) {
alert("修改成功")
a22[a3]=new1
// a22.push(new1)
console.log("所有用户名:"+a11)
console.log("所有新密码:"+a22)
}else{
alert("新密码不符合要求")
}
}else{
alert("新旧密码一样了")
}
} else{
alert("密码错误")
}
}
</script>
</body>
</html>