The div to be dragged is the outermost div. This Code binds the mouse listener event to the header of the displayed dialog box. When the mouse moves, the entire div is also moved as follows, if you are interested, refer to the following HTML code, where the p to be dragged is the outermost p
The Code is as follows:
Create user group
Group Name
User
Description
Confirm
Cancel
The js Code is as follows,
The Code is as follows:
$ ("# McreateUserGroup"). mousedown (function (e ){
Var flag = true;
E = e | event;
Var $ dialog_createUserGroup = $ ("# dialog_createUserGroup ");
Var LEFT = e. clientX-parseint(includialog_createusergroup.css ("left ")),
TOP = e. clientY-parseint(includialog_createusergroup.css ("top "));
$ (Document). mousemove (function (e ){
E = e | event;
If (flag ){
$Dialog_createUserGroup.css ({
"Left": e. clientX-LEFT + "px ",
"Top": e. clientY-TOP + "px"
});
}
});
$ (Document). mouseup (function (e ){
Flag = false;
});
});
This code binds the mouse listening event to the header of the displayed dialog box. When the mouse moves, the entire p moves accordingly!