<script type ="text/javascript">
$(document).ready(function() {
$(".a").draggable({ helper: "clone" });//这是复制
$("#b").droppable({
accept: function(draggable) { return $(draggable).hasClass("a"); },//这里指定接受器接受的条件我这里批定了只要是类a就能放进来
drop: function(draggable) {
$(this).append($("<div ></div>").html("被拖进的id")//这里提示不知提何得到(用js不知如何得到)
); } });
});
</script>
$(document).ready(function() {
$(".a").draggable({ helper: "clone" });//这是复制
$("#b").droppable({
accept: function(draggable) { return $(draggable).hasClass("a"); },//这里指定接受器接受的条件我这里批定了只要是类a就能放进来
drop: function(draggable) {
$(this).append($("<div ></div>").html("被拖进的id")//这里提示不知提何得到(用js不知如何得到)
); } });
});
</script>
当前object.id
这样看看能显示没,如果确实得到的是当前的object,应该是可以得到ID的
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title> <script src="../js/jquery.js" type="text/javascript"></script> <script src="../js/ui/jquery.ui.all.js" type="text/javascript"></script>
<script src="../js/ui/ui.draggable.js" type="text/javascript"></script> <script src="../js/ui/ui.droppable.js" type="text/javascript"></script>
<script type ="text/javascript">
$(document).ready(function() {
$(".a").draggable({ helper: "clone" });
$("#b").droppable({
accept: function(draggable) { return $(draggable).hasClass("a"); },
drop: function(draggable) {
$(this).append($("<div ></div>").html($(draggable).html() + "l")//这里提示找不到不知提何得到
); } });
});
</script>
<style type ="text/css">
.a{border: 1px solid #CCC; width :100px; height :100px;cursor:hand;}
#b{border: 1px solid #CCC; width :100px; height :100px;cursor:hand;}
</style>
</head>
<body>
<form id="form1" runat="server">
<div class="a" id="a1" >
红色
</div>
<div class="a" id="a2" >
绿色
</div>
<div id="b">
接受器
</div>
</form>
</body>
</html>
$(".a").draggable({ helper: "clone" });
$("#b").droppable({
accept: function(draggable) { return $(draggable).hasClass("a"); },
drop: function(draggable) {
(this).append($("<div ></div>").html(draggable.srcElement.id);
}});
});