ここに私のコードがあります。大きなdivの挿入/削除された要素を取り除きたいのですが、私のコードは私の助けてください。コードがそれは私のために動作しません。私はjqueryに新しいですガイドしてください。メインのdivの挿入された要素をドラッグして削除したい
$(function() {
$("ul li").each(function(){
$(this).draggable({
helper: "clone"
});
});
$(".day").droppable({
activeClass: "ui-state-hover",
hoverClass: "ui-state-active",
accept: ":not(.ui-sortable-helper)",
drop: function(event, ui) {
var targetElem = $(this).attr("id");
$(this).addClass("ui-state-highlight");
if($(ui.draggable).hasClass('draggable-source'))
$(ui.draggable).clone().appendTo(this).removeClass('draggable-source');
else
$(ui.draggable).appendTo(this);
// Remove element
$(ui.draggable).remove();
}
}).sortable({
items: "li:not(.placeholder)",
sort: function() {
$(this).removeClass("ui-state-default");
}
});
\t \t
});
h1 {font-family:Helvetica Neue, Helvetica, Arial, sans-serif;margin-top:0;font-size:36px;}
td {
text-align:;
\t \t \t display:inline-block;
}
tr:first-child td {
border-bottom:0;
border-top:0;
}
tr:nth-child(2) td {
border-top:0;
border-bottom:0;
}
td:first-child {
border-left:0;
}
td:last-child {
border-right:0;
}
div.day {
width:1000px;
\t \t \t min-height: 300px;
margin:0;
\t \t \t border: 1px solid black;
\t \t \t
}
div#drag {
width:120px;
height:40px;
padding:5px;
margin:5px;
display:inline-block;
text-align:center;
line-height: 40px;
font-family: Helvetica Neue, Helvetica, Arial, sans-serif;
font-weight: bold;
font-size:18px;
color:white;
text-shadow:0 1px 0 grey;
border:1px solid rgba(0,0,0,.1);
}
div#drag:hover {cursor:move;}
div#subjects ul li {
display:inline-block;
}
li, ul {
list-style-type: none;
}
<html>
<head>
<meta charset="utf-8">
<title>jQuery UI Droppable - Default functionality</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.13/jquery-ui.min.js"></script>
</head>
<body>
<table id="days">
<tr>
<td>Drag and Drop here</td>
</tr>
<tr>
<td>
<div id="div1" class="day monday ui-widget-content">
</div>
</td>
</tr>
</table>
<ul>
<li class="draggable-source">
<div style="background-color:brown;" id="drag">Element 1</div>
</li>
<li class="draggable-source">
<div style="background-color:orange;" id="drag">Element 2</div>
</li>
<li class="draggable-source">
<input id="drag" type="button" value="dragme">
</li>
</ul>
</body>
</html>
私は '(削除を参照することはできません)' – Bhumika107