zoukankan      html  css  js  c++  java
  • 鼠标拖拽,给图片打点,显示坐标

    核心代码:

    function move(){
    var x,y;
    $('.point').mousedown(function (){
    var _num = $(this).text();
    $(this).css('z-index','10');
    var _w=parseInt($(this).css("width"))/2;
    var _h=parseInt($(this).css("height"))/2;
    var marginTop = $('.img-box').offset().top;
    var marginLeft = $('.img-box').offset().left;
    $('.point-list .num'+_num+'').addClass('active').siblings().removeClass('active');
    $(this).mousemove(function (event){
    var ox=event.clientX-marginLeft;
    var oy=event.clientY-marginTop;
    var t=oy-_h;
    var l=ox-_w;
    var w=$('.img-box').width()-$('.point').width();
    var h=$('.img-box').height()-$('.point').height();
    if(t<0){
    t=0;
    }
    else if(t>h){
    t=h;
    }
    if(l<0){
    l=0;
    }
    else if(l>w){
    l=w;
    }
    x=parseInt(l+parseInt($(this).css('width'))/2);
    y=parseInt(t+parseInt($(this).css('height')));
    $(this).css({top:t,left:l});

    $('.point-list .num'+_num+' .x-num').html(x);
    $('.point-list .num'+_num+' .y-num').html(y);
    })
    });
    $('.point').mouseup(function (){
    $(this).unbind("mousemove");
    $(this).css('z-index','1');
    });
    }
  • 相关阅读:
    Beans
    Redis记录-Redis命令
    Redis记录-Redis介绍
    RESTful记录-RESTful服务
    RESTful记录-RESTful内容
    RESTful记录-RESTful介绍
    HTTP记录-HTTP介绍
    Solr记录-solr检索和查询数据
    Solr记录-solr文档xml
    Solr记录-solr内核与索引
  • 原文地址:https://www.cnblogs.com/duanyue/p/7065095.html
Copyright © 2011-2022 走看看