ext之创建子节点

huakaiwuxing 2014-04-28

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Ext JS in Action Chapter 02</title>
<link rel="stylesheet" type="text/css" href="./ext3/resources/css/ext-all.css" />
<style type="text/css">
	.myDiv {
		border: 1px solid #AAAAAA;
		width:200px;
		height : 35px;
		cursor: pointer;
		padding: 2px 2px 2px 2px;
	}
</style>
<script type="text/javascript" src="./ext3/adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="./ext3/ext-all-debug.js"></script>
<script type="text/javascript">
	Ext.BLANK_IMAGE_URL = './ext3/resources/images/default/s.gif'; 
</script>
<script type="text/javascript" src="./helloElement.js"></script>
</head>
<body> 
	<div id='div1' class="myDiv"></div> 
</body>
</html>
Ext.onReady(function() {
	var myDiv1 = Ext.get('div1');
	myDiv1.setSize(350, 350, {duration: 1, easing:'bounceOut'});
	myDiv1.createChild('<div>Element from a string</div>');
	myDiv1.createChild({
		tag  : 'div',
		html : 'Child from a config object'
	});
	myDiv1.createChild({
		tag   : 'div',
		id    : 'nestedDiv',
		style : 'border: 1px dashed; padding: 5px;',
		children : {
			tag   : 'div',
			html    : '...a nested div',
			style : 'color: #EE0000; border: 1px solid'
		} 
	});
	myDiv1.insertFirst({
		tag  : 'div',
		html : 'Child inserted as node 0 of myDiv1'
	});
	myDiv1.createChild({
		tag  : 'div',
		id   : 'removeMeLater',
		html : 'Child inserted as node 4 of myDiv1'
	},myDiv1.dom.childNodes[4]);
});

在<divid='div1'class="myDiv"></div>下创建子节点

相关推荐

zmjzhangmj / 0评论 2020-01-07