Sample Download
Plug-in name named: Jquery.tableresize.js, the code is as follows:
/*writen by Mlcactus, 2014-11-24 This is a jquery plugin I've encapsulated that allows columns of table to stretch left and right, making the width smaller or larger: a single table:$ ("#table_id"). Tableresize (); Page All table:$ ("table"). Tableresize (); */(function ($) {$.fn.tableresize = function () {var _document = $ ("body"); $ (this). each (function () {if (!$.tableresize) {$.tableresize = {}; } var _table = $ (this); Set 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 (); Set temporary variable storage object 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 + W Idth, 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 < bottom && (leftside | | rightside)) { _DOCUMENT.CSS ("cursor", "e-resize"); if (!cobjs._currentleft) {if (leftside) {cobjs._currentobj = _this.pre V (); } 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);
The page code is:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">The
makes a jquery plugin so that the title column of the table can be stretched left and right