<script src="js/jQuery8.3.js" type="text/javascript"></script>
<script type="text/javascript">
  $(document).ready(function(){
        $(".happy").click(function(){
              $(".loadbox").fadeIn("slow");
            });
        $(".no").click(function(){
              $(".loadbox").fadeOut("slow");
            });
          $(".loadbox").easydrag();
      });
</script>
插件网络下载:<script type="text/javascript" src="js/jquery.beta.js"></script>
(function($){

    // to track if the mouse button is pressed
var isMouseDown = false; // to track the current element being dragged
var currentElement = null; // callback holders
var dropCallbacks = {};
var dragCallbacks = {}; // bubbling status
var bubblings = {}; // global position records
var lastMouseX;
var lastMouseY;
var lastElemTop;
var lastElemLeft; // track element dragStatus
var dragStatus = {}; // if user is holding any handle or not
var holdingHandler = false; // returns the mouse (cursor) current position
$.getMousePosition = function(e){
var posx = 0;
var posy = 0; if (!e) var e = window.event; if (e.pageX || e.pageY) {
posx = e.pageX;
posy = e.pageY;
}
else if (e.clientX || e.clientY) {
posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
} return { 'x': posx, 'y': posy };
}; // updates the position of the current element being dragged
$.updatePosition = function(e) {
var pos = $.getMousePosition(e); var spanX = (pos.x - lastMouseX);
var spanY = (pos.y - lastMouseY); $(currentElement).css("top", (lastElemTop + spanY));
$(currentElement).css("left", (lastElemLeft + spanX));
}; // when the mouse is moved while the mouse button is pressed
$(document).mousemove(function(e){
if(isMouseDown && dragStatus[currentElement.id] != 'false'){
// update the position and call the registered function
$.updatePosition(e);
if(dragCallbacks[currentElement.id] != undefined){
dragCallbacks[currentElement.id](e, currentElement);
} return false;
}
}); // when the mouse button is released
$(document).mouseup(function(e){
if(isMouseDown && dragStatus[currentElement.id] != 'false'){
isMouseDown = false;
if(dropCallbacks[currentElement.id] != undefined){
dropCallbacks[currentElement.id](e, currentElement);
} return false;
}
}); // register the function to be called while an element is being dragged
$.fn.ondrag = function(callback){
return this.each(function(){
dragCallbacks[this.id] = callback;
});
}; // register the function to be called when an element is dropped
$.fn.ondrop = function(callback){
return this.each(function(){
dropCallbacks[this.id] = callback;
});
}; // disable the dragging feature for the element
$.fn.dragOff = function(){
return this.each(function(){
dragStatus[this.id] = 'off';
});
}; // enable the dragging feature for the element
$.fn.dragOn = function(){
return this.each(function(){
dragStatus[this.id] = 'on';
});
}; // set a child element as a handler
$.fn.setHandler = function(handlerId){
return this.each(function(){
var draggable = this; // enable event bubbling so the user can reach the handle
bubblings[this.id] = true; // reset cursor style
$(draggable).css("cursor", ""); // set current drag status
dragStatus[draggable.id] = "handler"; // change handle cursor type
$("#"+handlerId).css("cursor", "move"); // bind event handler
$("#"+handlerId).mousedown(function(e){
holdingHandler = true;
$(draggable).trigger('mousedown', e);
}); // bind event handler
$("#"+handlerId).mouseup(function(e){
holdingHandler = false;
});
});
} // set an element as draggable - allowBubbling enables/disables event bubbling
$.fn.easydrag = function(allowBubbling){ return this.each(function(){ // if no id is defined assign a unique one
if(undefined == this.id || !this.id.length) this.id = "easydrag"+(new Date().getTime()); // save event bubbling status
bubblings[this.id] = allowBubbling ? true : false; // set dragStatus
dragStatus[this.id] = "on"; // change the mouse pointer
$(this).css("cursor", "move"); // when an element receives a mouse press
$(this).mousedown(function(e){ // just when "on" or "handler"
if((dragStatus[this.id] == "off") || (dragStatus[this.id] == "handler" && !holdingHandler))
return bubblings[this.id]; // set it as absolute positioned
$(this).css("position", "absolute"); // set z-index
$(this).css("z-index", parseInt( new Date().getTime()/1000 )); // update track variables
isMouseDown = true;
currentElement = this; // retrieve positioning properties
var pos = $.getMousePosition(e);
lastMouseX = pos.x;
lastMouseY = pos.y; lastElemTop = this.offsetTop;
lastElemLeft = this.offsetLeft; $.updatePosition(e); return bubblings[this.id];
});
});
}; })(jQuery);

插件

JQ弹出框移动-插件分享~~~的更多相关文章

  1. Bootstrap 弹出框(Popover)插件

    Bootstrap 弹出框(Popover)插件与Bootstrap 提示工具(Tooltip)插件类似,提供了一个扩展的视图,用户只需要把鼠标指针悬停到元素上面即可.弹出框的内容完全由Bootstr ...

  2. 弹出框layer插件

    有时候我们在网页制作中需要引用各种弹出框,弹出框的展现形式多种多样.可以是弹出图片,视频,文字,也可以是弹出图片轮播等形式: 弹出框插件——layer使用方法(其实官方文档中已经介绍的很详细): 下载 ...

  3. 弹出框sweetalert插件的简单使用

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  4. 玩转Bootstrap(JS插件篇)-第1章 模态弹出框 :1-3 模态弹出框

    模态弹出框(Modals) 这一小节我们先来讲解一个“模态弹出框”,插件的源文件:modal.js. 右侧代码编辑器(30行)就是单独引入 bootstrap 中发布出的“modal.js”文件. 样 ...

  5. JS弹出框插件zDialog再次封装

    zDialog插件网址:http://www.jq22.com/jquery-info2426 再次封装zDialog的代码: (function ($) { $.extend({ iDialog: ...

  6. Bootstrap 弹出框和警告框插件

    一.弹出框 弹出框即点击一个元素弹出一个包含标题和内容的容器. //基本用法 <button class="btn btn-lg btn-danger" type=" ...

  7. jQuery+css3弹出框插件

    先来看DEMO:https://codepen.io/jonechen/pen/regjGG 插件的开发很简单,运用了CSS3的动画效果,并且弹出框的内容可以自定义.插件的默认配置参数有三个: var ...

  8. JavaScript插件——弹出框

    (JavaScript插件——弹出框) 前言 阅读之前您也可以到Bootstrap3.0入门学习系列导航中进行查看http://www.cnblogs.com/aehyok/p/3404867.htm ...

  9. Bootstrap入门(二十九)JS插件6:弹出框

    Bootstrap入门(二十九)JS插件6:弹出框 加入小覆盖的内容,像在iPad上,用于存放非主要信息 弹出框是依赖于工具提示插件的,那它也和工具提示是一样的,是需要初始化才能够使用的 首先我们引入 ...

随机推荐

  1. RDIFramework.NET平台代码生成器V2.8发布-更新于2014-12-31(提供下载)

    RDIFramework.NET平台代码生成器V2.8发布  更新于2014-12-31 注:已经发布了新版本,请转新版本下载: RDIFramework.NET平台代码生成器V3.0版本全新发布-更 ...

  2. mysql的一些基本操作语句

    -- 创建一个php2016的数据库create database php2016;-- 查看数据库的创建创建语句show create database php2016;-- 指定默认的操作数据库u ...

  3. ssh安装与配置

    SSH 为 Secure Shell 的缩写,由 IETF 的网络工作小组(Network Working Group)所制定:SSH 为建立在应用层和传输层基础上的安全协议. 传统的网络服务程序,如 ...

  4. android 手风琴

    引用:http://note.youdao.com/share/?id=994df799c2dcc8d83a8909173e42f80d&type=note 先看效果,过瘾一番. 源码下载:h ...

  5. 11. 星际争霸之php设计模式--备忘模式

    题记==============================================================================本php设计模式专辑来源于博客(jymo ...

  6. Css Study - 横向MENU

    http://cssmenumaker.com/menu/tabbed-chrome-and-blue HTML <div id="topMenu"> <ul&g ...

  7. maven私有库配置

    私有库的配置 协同开发过程中私有库可以为团队提升很大效率,之前我的私有库一直存在问题导致jar包导入异常.现在在这分享一下私有库配置的几个点,可能因为我们学校比较简陋所以配置的比较简单,欢迎大家补充 ...

  8. Java通过继承thread类与实现Runnable接口实现多线程的区别

    Java中线程的创建有两种方式: 1.  通过继承Thread类,重写Thread的run()方法,将线程运行的逻辑放在其中 2.  通过实现Runnable接口,实例化Thread类 一.通过继承T ...

  9. Python学习笔记-常用模块

    1.python模块 如果你退出 Python 解释器并重新进入,你做的任何定义(变量和方法)都会丢失.因此,如果你想要编写一些更大的程序,为准备解释器输入使用一个文本编辑器会更好,并以那个文件替代作 ...

  10. C#单独启动进程的几种方式

    本文实例讲述了C#启动进程的几种常用方法.分享给大家供大家参考.具体如下: 1.启动子进程,不等待子进程结束 private void simpleRun_Click(object sender, S ...