Jquery - 动态更改表的行高。
我正在使用 Jquery 的数据表。我有一个 id =“affectedRegion”的表。它有一个列,里面有一个单选按钮。在某种程度上,该单选按钮单元格周围的一些样式赋予了每行其高度。
在特殊情况下,我必须通过执行类似的操作来隐藏单选按钮列
affectedRegion.fnSetColumnVis(0, false);
但是,当我这样做时,行变得比我想要的短得多。由于此代码在许多其他地方共享,我想知道 Jquery 中是否有一种方法可以动态更改行高以保持相同的外观和感觉。
我尝试了下面的方法,但它不起作用。
$("#affectedRegion").css('height', '25px');
提前感谢您的帮助。
I am using a Jquery's datatable. I have a table with id = "affectedRegion". It has a column with a radio button inside it. In part, some of the styling around this radio button cell gives each row it's height.
In a special case, I have to hide the radio button column by doing something like this
affectedRegion.fnSetColumnVis(0, false);
However, when I do this, the rows become much shorter than what I want. Since this code is shared at many other places, I would like to know if there is a way in Jquery that I can change the row height dynamically to maintain the same look and feel.
I tried the below and it doesn't work.
$("#affectedRegion").css('height', '25px');
Thanks for your help in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我设置了一个简单的 jsFiddle 来演示设置表格行的行高,它似乎工作正常。我正在使用 Chrome,如果有帮助的话。
我正在更改
标记的高度(如果有帮助的话)。
如果您还有其他问题,请告诉我,我会更新我的答案。
祝你好运。希望这有帮助。
更新更新了我的小提琴。如果您有权访问要调整大小的行的索引,则可以使用 jQuery 的 eq 函数仅影响表中的该表行。我不确定这是否有帮助,但这可以让您摆脱为每行分配 id 或某种标记类的情况。
I set up a simple jsFiddle to demo setting the row height of a table row, and it seems to work fine. I'm using Chrome, if that helps.
I'm changing the height of the
<tr>
tag, if that helps.If you have other questions, let me know and I'll update my answer.
Good luck. Hope this helps.
UPDATE Updated my fiddle here. If you have access to the index of the row to be resized, you can use jQuery's
eq
function to only affect that table row in your table. I'm not sure if this helps or not, but this allows you to get away from having an id or some sort of marker class assigned to each row.