14.js(生成表格)(全选/反选)(实时时钟)

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
        <input id="hang" placeholder="请输入行数"></br>
        <input id="lie" placeholder="请输入列数">
        <input type="button" onclick="shengcheng()" value="确认生成">
        <table border="1px" id="biaoge" cellpadding="10px" cellspacing="0px"></table>
        <script>
            function shengcheng(){
                var hang=document.getElementById("hang").value;
                hang=parseInt(hang)//取值行数
                var lie=document.getElementById("lie").value;
                lie=parseInt(lie)//取值列数
                var biaoge=document.getElementById("biaoge")//获取对象
                for(i=1;i<=hang;++i){
                    x=document.createElement("tr")
                    biaoge.appendChild(x)//在table里添加tr
                        for(z=1;z<=lie;++z){
                            x.appendChild(document.createElement("td"))//在tr里添加td
                        }
                }
            }
        </script>
	</body>
</html>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
        <input type="checkbox" value="羽毛球" name="hobby" >羽毛球</br>
        <input type="checkbox" value="马拉松" name="hobby">马拉松</br>
        <input type="checkbox" value="乒乓球" name="hobby">乒乓球</br>
        <input type="checkbox" value="跆拳道" name="hobby">跆拳道</br>
        <input type="checkbox" value="击剑" name="hobby">击剑</br>
        <input type="button" value="全选" onclick="x()"></br>
        <input type="button" value="全不选" onclick="a()">
        <script>
            function x(){
                y=document.getElementsByName("hobby")
                for(i=0;i<y.length;++i){
                    y[i].checked=true
                }
            }
            function a(){
                y=document.getElementsByName("hobby")
                for(i=0;i<y.length;++i){
                    y[i].checked=false
                }
            }
        </script>
	</body>
</html>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
        <div id="times"></div>
        <script>
            function time(){document.getElementById("times").innerHTML=new Date().getFullYear()+"年"+(new Date().getMonth()+1)+"月"+new Date().getDate()+"日"+new Date().getHours()+":"+new Date().getMinutes()+":"+new Date().getSeconds()}
            setInterval(time,1000)//一秒刷新一次
        </script>
	</body>
</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值