1. <tt id="5hhch"><source id="5hhch"></source></tt>
    1. <xmp id="5hhch"></xmp>

  2. <xmp id="5hhch"><rt id="5hhch"></rt></xmp>

    <rp id="5hhch"></rp>
        <dfn id="5hhch"></dfn>

      1. jQuery實現(xiàn)的拖動調(diào)整表格單元格的大小代碼實例

        時間:2020-11-11 09:58:33 jQuery 我要投稿

        jQuery實現(xiàn)的拖動調(diào)整表格單元格的大小代碼實例

          jQuery實現(xiàn)的拖動調(diào)整表格td單元格的大小:

          在實際應(yīng)用中,可能有這樣的'需求,那就是需要調(diào)整td單元格的大小。

          也許是為了便于觀察,也許是其他原因,反正這樣的需求是有的,下面就分享一段能夠?qū)崿F(xiàn)此功能的代碼。

          代碼實例如下:

          復(fù)制代碼 代碼如下:

          table {

          border-collapse: collapse;

          }

          td {

          text-align: center;

          }

          (function ($){

          $.fn.tableresize = function () {

          var _document = $("body");

          $(this).each(function () {

          if (!$.tableresize) {

          $.tableresize = {};

          }

          var _table = $(this);

          //設(shè)定ID

          var id = _table.attr("id") || "tableresize_" + (Math.random() * 100000).toFixed(0).toString();

          var tr = _table.find("tr").first(), ths = tr.children(), _firstth = ths.first();

          //設(shè)定臨時變量存放對象

          var cobjs = $.tableresize[id] = {};

          cobjs._currentObj = null, cobjs._currentLeft = null;

          ths.mousemove(function (e) {

          var _this = $(this);

          var left = _this.offset().left,

          top = _this.offset().top,

          width = _this.width(),

          height = _this.height(),

          right = left + width,

          bottom = top + height,

          clientX = e.clientX,

          clientY = e.clientY;

          var leftside = !_firstth.is(_this) && Math.abs(left - clientX) <= 5,

          rightside = Math.abs(right - clientX) <= 5;

          if (cobjs._currentLeft||clientY>top&&clientY

          _document.css("cursor", "e-resize");

          if (!cobjs._currentLeft) {

          if (leftside) {

          cobjs._currentObj = _this.prev();

          }

          else {

          cobjs._currentObj = _this;

          }

          }

          }

          else {

          cobjs._currentObj = null;

          }

          });

          ths.mouseout(function (e) {

          if (!cobjs._currentLeft) {

          cobjs._currentObj = null;

          _document.css("cursor", "auto");

          }

          });

          _document.mousedown(function (e) {

          if (cobjs._currentObj) {

          cobjs._currentLeft = e.clientX;

          }

          else {

          cobjs._currentLeft = null;

          }

          });

          _document.mouseup(function (e) {

          if (cobjs._currentLeft) {

          cobjs._currentObj.width(cobjs._currentObj.width() + (e.clientX - cobjs._currentLeft));

          }

          cobjs._currentObj = null;

          cobjs._currentLeft = null;

          _document.css("cursor", "auto");

          });

          });

          };

          })(jQuery);

          $(document).ready(function () {

          $("table").tableresize();

          });


                    

                    

                    
        ID
        名字
        年紀(jì)
        地址
        電話

                    
        22
        Name:44
        Age:23
        Address:47
        Phone:15

                    
        28
        Name:42
        Age:68
        Address:30
        Phone:50

                    
        29
        Name:63
        Age:48
        Address:90
        Phone:76

        【jQuery實現(xiàn)的拖動調(diào)整表格單元格的大小代碼實例】相關(guān)文章:

        1.JavaScript實現(xiàn)的div拖動效果實例代碼

        2.jquery異步請求的實例代碼

        3.jQuery的合并表格中相同文本的相鄰單元格的代碼

        4.基于jQuery的固定表格頭部的代碼

        5.jquery中EasyUI同步樹的實現(xiàn)代碼

        6.jquery下json數(shù)組的操作如何實現(xiàn)代碼

        7.jQuery中data()方法的語法結(jié)構(gòu)及實例代碼

        8.jQuery實現(xiàn)左右圖片輪播代碼操作方法

        国产高潮无套免费视频_久久九九兔免费精品6_99精品热6080YY久久_国产91久久久久久无码

        1. <tt id="5hhch"><source id="5hhch"></source></tt>
          1. <xmp id="5hhch"></xmp>

        2. <xmp id="5hhch"><rt id="5hhch"></rt></xmp>

          <rp id="5hhch"></rp>
              <dfn id="5hhch"></dfn>