JQuery implements a complete instance of layer that can be scaled in the lower right corner. jquery scales

Source: Internet
Author: User

JQuery implements a complete instance of layer that can be scaled in the lower right corner. jquery scales

This example describes how to scale a layer in the lower right corner of jQuery. We will share this with you for your reference. The details are as follows:

<! Doctype html public "-// W3C // dtd html 4.01 // EN" "http://www.w3.org/TR/html4/strict.dtd"> 

After the function is encapsulated:

function resize(div){  div.mousemove(function(e){    var e = e || window.event;    var posx = e.clientX;    var posy = e.clientY;    var l = div.offset().left;    var t = div.offset().top;    var h = div.height();    var w = div.width();    var ol = l+w-10;    var or = l+w+10;    var ot = t+h-10;    var ob = t+h+10;    $(this).css("cursor","");    if(posx>ol && posx<or && posy >ot && posy<ob){      $(this).css("cursor","nw-resize");    }  });  div.mousedown(function(e){    var e = e || window.event;    var posx = e.clientX;    var posy = e.clientY;    var l = div.offset().left;    var t = div.offset().top;    var h = div.height();    var w = div.width();    var ol = l+w-10;    var or = l+w+10;    var ot = t+h-10;    var ob = t+h+10;    if(posx>=ol && posx<=or && posy >=ot && posy<=ob){      document.onmousemove = function(e){        var e = e || window.event;        var currX = e.clientX;        var currY = e.clientY;        div.width(w + (currX - posx));        div.height(h+(currY-posy));      }      $(document).mouseup(function(){        document.onmousemove = null;      });    }  });}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.