两个单独的表上的Td高度 [英] Td height on two separate tables

查看:102
本文介绍了两个单独的表上的Td高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个单独的表,我在每个tr上使用focus + hover函数在两个表上同时工作伟大,我的问题是与td高度,因为如果一个td从fist表的描述更大将显示在在同一td中的两行和td的高度将被修改,但只会进入第一个表td。如何可能记住从第一个表到td的高度,并添加到td从第二个表,以便具有相同的大小。
在我的例子中,只有前两个tr显示ok,其他两个显示不正确,因为第一个表td的描述。



fiddle例子:
http://jsfiddle.net/Ksb2W/45/

  for bounty请检查此示例以查看chrome和ie8上的差异:

http://mainpage.ueuo.com/



谢谢。

解决方案

如果我正确理解你,



如果是这样,这应该工作:

  $(table:first tr)。each(function(i){
$(table:last tr)。eq(i).height($(this).height ());
});

显然使用:first code>:last 选择器不太理想,应该将它们修改为 id 选择器。



示例小提琴






UPDATE



您在赏金中提及的问题的解决方案是因为 td 元素的边界未计入。



替换 height ) outerHeight()检查当前行,它应该工作很好:



<$每个(函数(i){
$(table:last tr)。eq(i).height this).outerHeight());
});


I have two separate tables on which I use a focus+hover function on each tr that works great on both tables simultaneous, my problem is with td height because if the description of a td from fist table is greater will be displayed on two rows in the same td and the height of td will be modified but only into first table td. How is possible to remember the height to the td from first table and to add that on td from second table in order to have both td same size. In my example only first two tr are displayed ok the other two are displayed not ok because of description of first table td.

fiddle example: http://jsfiddle.net/Ksb2W/45/

   for bounty  please check this example to see the difference on chrome and ie8:

http://mainpage.ueuo.com/

Thank you.

解决方案

If I've understood you correctly you want the heights within each row of both tables to be the same?

If so, this should work:

$("table:first tr").each(function(i) {
    $("table:last tr").eq(i).height($(this).height());
});

Obviously the use of :first and :last selectors is not ideal, you should amend those to be id selectors.

Example fiddle


UPDATE

The solution to the problem you've mentioned in your bounty is because of the border on the td elements not being accounted for.

Replace height() with outerHeight() when checking the current row and it should work fine:

$("table:first tr").each(function(i) {
    $("table:last tr").eq(i).height($(this).outerHeight());
});

这篇关于两个单独的表上的Td高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆