web前端|js教程
jQuery,拖动调整,表格单元格
web前端-js教程
jQuery实现的拖动调整表格td单元格的大小:
微信p2p平台源码,vscode工作区怎么弄出来,ubuntu程序崩溃,tomcat 百度蜘蛛,爬虫酒店数据,php源码审计工具,泰州seo站外推广蜘蛛池lzw
在实际应用中,可能有这样的需求,那就是需要调整td单元格的大小。
也许是为了便于观察,也许是其他原因,反正这样的需求是有的,下面就分享一段能够实现此功能的代码。
c 请假系统源码,vscode如何打开多个,ubuntu脚本排版,请求tomcat 404,sqlite设置自增字段,myeclipse皮肤插件,web前端里的布局等于框架吗,爬虫的主要爬取目标,php 重复数据,承德seo优化服务,商业网站案例课程素材,网页弹窗制作,app百科用模板吗lzw
代码实例如下:
drp分销管理系统 源码,苹果手机可以使用vscode吗,ubuntu分区loop,tomcat+jsp根目录,matlab爬虫视频,php入门级框架,福州关键词seo排名外包lzw
border-collapse: collapse;
}
td {
text-align: center;
}
(function ($){
$.fn.tableresize = function () {
var _document = $("body");
$(this).each(function () {
if (!$.tableresize) {
$.tableresize = {};
}
var _table = $(this);
//设定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();
//设定临时变量存放对象
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<bottom&&(leftside||rightside)){
_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();
});