الأجوبة
HTML Code :
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-git.js"></script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Move one DIV element inside another.</title>
</head>
<body>
<div id="nonSelected">
<!--Declaring BUTTON TAGS -->
<button id="btnDefault" onclick="moveButton(this)" type="button">Button1</button>
<button id="btnPrimary" onclick="moveButton(this)" type="button" >Button2</button>
<button id="btnDanger" onclick="moveButton(this)" type="button">Button3</button>
</div>
<div id="selected">
</div>
</body>
</html>
CSS Code :
#nonSelected{
position: absolute;
top: 10px;
left: 10px;
width: 180px;
height: 180px;
background-color: #884333;
border-width: 1px;
border-style: dotted;
border-color: black;
padding: 10px;
}
#selected{
position: absolute;
top: 10px;
left: 200px;
width: 180px;
height: 180px;
background-color: #498933;
border-width: 1px;
border-style: dotted;
border-color: black;
padding: 10px;
}
JavaScript Code :
function moveButton(elem){
if( $(elem).parent().attr("id") == "nonSelected" ){
$(elem).detach().appendTo('#selected');
}
else{
$(elem).detach().appendTo('#nonSelected');
}
}
أسئلة مشابهة
القوائم الدراسية التي ينتمي لها السؤال
معلومات ذات صلة