表格行示例:
<tr class="row"><td>Blah</td><td>Blah 2</td></tr>
如何从这里出发:
$('row').click(function(){
});
那么,当单击该行的 td 单元格时,是否会给出该行右上角的 (x,y) 坐标?
最佳答案
您可能正在寻找offset()或position() ,取决于距离应相对于:
$('row').click(function(){
$(this).offset(); //returns an object with top and left values relative to the document
//or
$(this).position(); //returns an object with top and left values relative to the parent
});
通常像这样使用(两种方法相同):
$('row').click(function(){
var left = $(this).offset().left + $(this).width(),
top = $(this).offset().top;
});
关于jquery - 如何获取表格行的右上角 (x,y) 坐标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13782419/