当前位置 : 主页 > 网页制作 > Dojo >

dojo-复选框

来源:互联网 收集:自由互联 发布时间:2021-06-15
1、问题背景 设计一组复选框,并获取复选框的值 2、实现源码 !DOCTYPE htmlhtmlheadmeta charset="UTF-8"titledojo-复选框/titlelink rel="stylesheet" href="../js/dojo-release-1.11.1-src/dijit/themes/claro/claro.css" /sc

1、问题背景

     设计一组复选框,并获取复选框的值


2、实现源码

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>dojo-复选框</title>
		<link rel="stylesheet" href="../js/dojo-release-1.11.1-src/dijit/themes/claro/claro.css" />
		<script type="text/javascript" src="../js/jquery-1.12.4.js"></script>
		<script type="text/javascript" src="../js/dojo-release-1.11.1-src/dojo/dojo.js"></script>
		<style>
			body,html{
				width: 99%;
				height: 99%;
				font-family: "微软雅黑";
				font-size: 12px;
				overflow: hidden;
			}
		</style>
		<script>  
            dojoConfig={async:true,parseOnLoad:true}  
        </script> 
		<script>
			require(["dijit/form/CheckBox", "dojo/domReady!"], function(CheckBox){
			    var checkBox = new CheckBox({
			        name: "checkBox",
			        value: "男",
			        checked: false,
			        onChange: function(b){ 
			        	alert(this.get('value') ); 
			        }
			    }, "man").startup();
			   
			   var checkBox1 = new CheckBox({
			        name: "checkBox",
			        value: "女",
			        checked: false,
			        onChange: function(b){ 
			        	alert(this.get('value') ); 
			        }
			    }, "woman").startup();
			});
		</script>
	</head>
	<body class="claro">
		<input id="man" /> 
		<label for="man">男</label>
		<input id="woman" /> 
		<label for="woman">女</label>
	</body>
</html>

3、实现结果

(1)当勾选“男”时


(2)当勾选“女”时

网友评论