jQuery可调整大小:在停止事件时获取第一个td值

jQuery可调整大小:在停止事件时获取第一个td值,jquery,resizable,Jquery,Resizable,我有一张像日历的桌子 请看一下代码片段,很难解释我想从jQuery中得到什么 当您查看该表时,您将在第一个td中找到时间 当我从08:00开始调整div的大小到09:00时,我想得到tr的索引,其中第一个td的值为09:00 $('#resize').resizable({ grid: 45, resize: function(event, ui) { ui.size.width = ui.originalSize.width; }, stop:

我有一张像日历的桌子

请看一下代码片段,很难解释我想从jQuery中得到什么

当您查看该表时,您将在第一个
td
中找到时间

当我从08:00开始调整div的大小到09:00时,我想得到
tr
的索引,其中第一个
td
的值为09:00

$('#resize').resizable({
    grid: 45,
    resize: function(event, ui) {
        ui.size.width = ui.originalSize.width;
    },
    stop: function( event, ui ) {
        //*********** 
        // THIS WILL ONLY GIVE ME THE INDEX WHERE THE DIV BEGINS
        // BUT I WANT TO HAVE THE INDEX WHERE THE DIV ENDS AFTER RESIZING
        var index = $(this).parent().parent().index();
    }
});
我只能获取
div
开始的索引,即08:00。但是我想得到
div
结束的索引。所以09:00

非常感谢大家

编辑:

我还尝试获取鼠标位置,并获取最近的
td
tr

我只获得鼠标位置,但无法访问
tr
索引

$('#test')。可调整大小()
.dragDiv{
背景色:#14A07D;
背景:线性梯度(#1BD6A7,#14A07D);
背景剪辑:填充框;
显示:表格;
文本对齐:居中;
宽度:100%;
身高:100%;
位置:绝对位置;
溢出:隐藏;
z指数:2;
顶部:0px;
左:0px;
颜色:#FFFFFF;
字体大小:粗体;
空白:预处理;
边界半径:2px;
}
.德拉格迪夫:悬停{
光标:-webkit抓取;
光标:-moz抓取;
背景:#ff0080;
背景:线性梯度(#fe78ad,#ff0080);
}
桌子{
宽度:100%;
边界塌陷:塌陷;
字体大小:13px;
边界半径:10px;
-webkit边界半径:10px;
-moz边界半径:10px;
背景色:#FFFFFF;
}
桌子
th,
运输署{
边框底部:1px虚线#f0ec;
边框顶部:1px虚线#f0ec;
右边框:1px实心#e9e9e4;
右边框:1px实心#e9e9e4;
*高度:16px;
字体大小:12px;
文本对齐:居中;
}
运输署{
位置:相对位置;
}

08:00
1.
试验
2.
3.
4.
5.
6.
08:30
1.
2.
3.
4.
5.
6.
09:00
1.
2.
3.
4.
5.
6.
09:30
1.
2.
3.
4.
5.
6.
这就成功了

// get the bottom coordinate of the resized DIV 
var y = ($(this).offset().top + ui.size.height);

// get the x coordinate
var x = $(this).offset().left;

// get all elements below the calculated point
var elem = document.elementFromPoint(x, y);

// get the element "tr" of all elements and fetch the ID
var time = $('td:first', $(elem).parents('tr')).attr('id');
这就是诀窍

// get the bottom coordinate of the resized DIV 
var y = ($(this).offset().top + ui.size.height);

// get the x coordinate
var x = $(this).offset().left;

// get all elements below the calculated point
var elem = document.elementFromPoint(x, y);

// get the element "tr" of all elements and fetch the ID
var time = $('td:first', $(elem).parents('tr')).attr('id');

我发现这在FF和IE中不起作用。
文档。elementFromPoint(x,y)
返回我开始调整分区大小的第一个
td
值。Chrome返回我停止调整分区大小的
td
值。很奇怪!!有什么想法吗?我发现这在FF和IE中不起作用。
文档。elementFromPoint(x,y)
返回我开始调整分区大小的第一个
td
值。Chrome返回我停止调整分区大小的
td
值。很奇怪!!有什么想法吗?