给作业分类加个全选

原创 2018-11-10 23:55:10 198
摘要:<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>全选</title> <style type="text/css"> .box{width: 650px;b
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>全选</title>
	<style type="text/css">
	.box{width: 650px;border: 1px solid #000;border-radius: 5px;margin: 100px auto;padding: 20px;}
	.box input{margin: 10px;}
	</style>
	<script type="text/javascript">
	function checkAll(){
		var checkall,item;
		checkall=document.getElementById('checkall');
		item=document.getElementsByName("item[]");
		for(var i=0;i<item.length;i++){
		if(checkall.checked){
			item[i].checked=true;
		}else{
			item[i].checked=false;
		}

	}
}
	</script>
</head>
<body>
<div class="box">
	<span>请选择分类</span>
	<div>
		<input type="checkbox" id="checkall" onclick="checkAll()"><label for="checkall">全选</label>
	</div>
	<input type= "checkbox" name="item[]"> PHP&nbsp; &nbsp; 
		<input type= "checkbox" name="item[]"> MySQL&nbsp; &nbsp; 
		<input type= "checkbox" name="item[]"> HTML&nbsp; &nbsp; 
		<input type= "checkbox" name="item[]"> CSS&nbsp; &nbsp; 
		<input type= "checkbox" name="item[]"> JavaScript&nbsp; &nbsp; 
		<input type= "checkbox" name="item[]"> jQuery&nbsp; &nbsp;
		<input type= "checkbox" name="item[]"> AJAX&nbsp; &nbsp; 
		<input type= "checkbox" name="item[]"> Html5&nbsp; &nbsp; 
		<input type= "checkbox" name="item[]"> CSS3&nbsp; &nbsp; 
		<input type= "checkbox" name="item[]"> Linux&nbsp; &nbsp; 
		<input type= "checkbox" name="item[]"> Redis&nbsp; &nbsp; 
		<input type= "checkbox" name="item[]"> Mencached&nbsp; &nbsp; 
</div>
</body>
</html>

学习javascript的脚步快了些,老师讲述的Javascript事件还未逐个去使用掌握,对css的排版并没有很熟练!未能达到自己想要的结果,对知识点掌握的不够透彻吧!还有写代码也不够仔细,少了个}找了半天,头大。

批改老师:灭绝师太批改时间:2018-11-11 09:38:11
老师总结:慢慢来 新手都会遇到这种问题 一遍不行两遍……基础打好,后面就会好很多

发布手记

热门词条