81,115
社区成员
发帖
与我相关
我的任务
分享<html>
<head>
<title>test</title>
<script type="text/javascript">
function $(id) {
return document.getElementById(id);
}
function hadThisChild(parent, child) {
var children = parent.children;
for(var i = 0; i < children.length; i ++) {
if(child.innerText == children[i].innerText) {
return true;
}
}
return false;
}
function add_project() {
var value = $("file_selected").value;
var ele_div = document.createElement("div");
ele_div.style.cursor = "hand";
ele_div.attachEvent('onclick', function(event) {
$('right_div').removeChild(event.srcElement);
});
ele_div.innerText = value;
if(!hadThisChild($('right_div'), ele_div)) {
$('right_div').appendChild(ele_div);
}
}
</script>
</head>
<body>
<div style="width: 850px;">
<div id="left_div" style="float: left; width: 300px; height: 600px; border: 1px solid #BBBBBB; margin-right: 5px;">
<input type="file" id="file_selected" /><br />
<input type="button" value="Add" onclick="add_project();"/>
</div>
<div id="right_div" style="float: right; width: 500px; height: 600px; border: 1px solid #BBBBBB;">
</div>
</div>
</body>
</html>