Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 可拖动的Bug:当我按住其中一个div并拖动时,div可能会不正常,但当我放下时会恢复正常吗?_Jquery_Jquery Ui_Html_Jquery Ui Draggable - Fatal编程技术网

Jquery 可拖动的Bug:当我按住其中一个div并拖动时,div可能会不正常,但当我放下时会恢复正常吗?

Jquery 可拖动的Bug:当我按住其中一个div并拖动时,div可能会不正常,但当我放下时会恢复正常吗?,jquery,jquery-ui,html,jquery-ui-draggable,Jquery,Jquery Ui,Html,Jquery Ui Draggable,我创建了6个div并设法将它们放在一个盒子里,当我拖动其中一个div时,我的其他div似乎会移动到另一个地方,甚至跳出盒子 但是当我放下潜水器时,一切都回到了原来的位置 有人能解释为什么会这样吗 这是我的密码 <html> <head> <script src="http://code.jquery.com/jquery-1.9.1.js"></script> <script src="http://code.jquery.com/u

我创建了6个div并设法将它们放在一个盒子里,当我拖动其中一个div时,我的其他div似乎会移动到另一个地方,甚至跳出盒子

但是当我放下潜水器时,一切都回到了原来的位置

有人能解释为什么会这样吗

这是我的密码

<html>
<head>
  <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
  <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
    <title>Javascript Create Div Element Dynamically</title>

    <style type="text/css">
.ex
{
width:200px;
position: relative;
background-color :#CCC;
height:150px;
padding:10px;
margin:5px;
left-margin:0px;
float :left;
}
#newdiv
{
    width:800px;
    height:800px;
 border:1px solid #000;     
}
.border
{
 border:1px solid #000; 
}

    </style>
<script>

image.cc=1;
function changeimage(image)
{
if (image.cc==0) 
  {
  image.cc=1;
  $(image).attr('src', 'images/white_contact.png');
  }
else if (image.cc==1)
  {
  image.cc=2;
  $(image).attr('src', 'images/yellow_contact.png');
  }
  else if (image.cc==2)
  {
  image.cc=3;
    $(image).attr('src', 'images/green_contact.png');
  }
    else
  {
  image.cc=0;
    $(image).attr('src', 'images/red_contact.png');
  }
}
</script>
 <script type="text/javascript" language="javascript">
var i=0;
    function createDiv()
    {


  if(i < 6) {
        var divTag = document.createElement("div");

        divTag.id = "div1";

        divTag.setAttribute("align","left");

        divTag.style.margin = "0px auto";

        divTag.className ="ex";

       divTag.innerHTML = "<img class='myimage' onclick='changeimage(this)' border='0' src='images/white_contact.png' width='60'/>";

        document.getElementById("newdiv").appendChild(divTag)

      }

   i++;
   $( ".ex" ).draggable({containment:'parent',cursor:'pointer',opacity:0.6});
 $( ".ex" ).droppable({ hoverClass:'border' });

    }





    </script>
</head>
<body>

    <p align="left">
        <b>Click this button to create div element dynamically:</b>
        <input id="btn1" type="button" value="create div" onClick="createDiv();" />

        <div id = "newdiv">

</div>
    </p>

</body>
</html>

你能和我分享这个吗?我能上传到这里吗