Home > front end >  Ask bosses on js div drag effect div internal input cannot be used
Ask bosses on js div drag effect div internal input cannot be used

Time:09-19

Code is as follows: can now implement the drag effect of div but div inside there are several input need input values, but now the input you can normal use the mood, help solve

Var box=document. GetElementById (" batchAdd ");
Box. onm ousedown=function (ev) {
Var oEvent=ev | | event;
Var x=oEvent. ClientX - box. The offsetLeft;
Var y=oEvent. ClientY - box. OffsetTop;
Document. The onm ousemove=function (ev) {
Var oEvent=ev | | event;
Var. L=oEvent clientX - x;
Var t=oEvent. ClientY - y;
If (l & lt; 0 {
L=0;
} else if (l & gt; Document. The documentElement. ClientWidth - box. OffsetWidth) {
L=the document. The documentElement. ClientWidth - box. OffsetWidth;
}
If (t & lt; 0 {
T=0;
} else if (t & gt; Document. The documentElement. ClientHeight - box. OffsetHeight) {
T=document. DocumentElement. ClientHeight - box. OffsetHeight;
}
Box. Style. Left=l + "px";
Box. The style. The top=t + "px";
}
Document. The onm ouseup=function () {
Document. The onm ousemove=null;
Document. The onm ouseup=null;
}
return false;
}
  • Related