dojo-复选框

前端之家收集整理的这篇文章主要介绍了dojo-复选框前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

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: "女","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)当勾选“女”时

猜你在找的Dojo相关文章