Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/entity-framework/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 如何将tr置于div内_Jquery - Fatal编程技术网

Jquery 如何将tr置于div内

Jquery 如何将tr置于div内,jquery,Jquery,我有一个div,溢出-y:auto,高度为X。 里面有一个表,行和ID= y的行,我想在div的视图端口中间放置行y。 我如何在Jquery中实现它?代码: <div id="outerDiv" style="height:200px;overflow-y:Auto;"> <table id="innerTable" > <tr><td> ....</tr> <tr><td>

我有一个div,溢出-y:auto,高度为X。 里面有一个表,行和ID= y的行,我想在div的视图端口中间放置行y。 我如何在Jquery中实现它?代码:

<div id="outerDiv" style="height:200px;overflow-y:Auto;">
    <table id="innerTable" >
       <tr><td> ....</tr>
       <tr><td> ....</tr>
       <tr><td> ....</tr>
       <tr><td> ....</tr>
       <tr id="centerMe"><td> ....</tr>
       <tr><td> ....</tr>
    </table>
</div>

....
....
....
....
....
....

您应该尝试使用该插件。这使得滚动容器以显示特定项变得非常容易。

您必须使用表吗?表不是邪恶的,它们对行数据是有益的;你说的是水平中心还是垂直中心(或两者兼而有之)?我用过它,但容器div会滚动到raw的顶部,我希望raw位于div高度的垂直中间。请参阅offset选项;您应该能够使用容器的高度/2作为y偏移量。我要查找的是计算结果,而不是方法。常规对中逻辑:
(container.height()/2)-(row.height()/2)
。如果使用scrollTo并将其用作偏移量,则应该居中。因此,它是$('容器')。scrollTo($('中间原始'),'慢速',{offset:{y:$('中间原始'),height()/2});