I have a table in an app with data and the thead element in the table has a variable height depending on what user is logged in and using the application. So sometimes the thead element is narrow in height and sometimes it's much taller. Note that there are only two heights that are possible.

我在应用程序中有一个包含数据的表,表中的thead元素有一个可变高度,这取决于用户登录和使用应用程序。所以有时候thead元素的高度很窄,有时更高。注意,只有两个高度是可能的。

I'd like to somehow use jquery to measure the height of the thead element and then add a class so it might come out like this:

我想用jquery来测量thead元素的高度,然后添加一个类,它可能会是这样的:

Narrow:

狭窄:

<thead class="narrow">

Tall:

高:

<thead class="tall">

I am not even sure if this is possible. Thanks.

我甚至不确定这是否可行。谢谢。

2 个解决方案

#1


5

It sounds like you're looking for the height function

听起来你在寻找高度函数。

  • http://api.jquery.com/height/
  • http://api.jquery.com/height/

With that you can write code like the following

这样,您就可以编写如下代码

var t = $('thead');
t.addClass(t.height() > someValue ? "tall" : "narrow");

更多相关文章

  1. 单个元素html上的多个类
  2. 样式通常以相同的组合出现:创建单个类还是组合元素?
  3. 在href元素中使用标记<c:out [duplicate]
  4. IFrame中的Div没有达到给定的高度
  5. CSS3列 - 添加第二个元素后的额外宽度
  6. Chrome 50更改隐式表格单元格高度行为
  7. 垂直对齐div中的两个元素
  8. 如何用c#获取服务器端元素的innerhtml(内部有另一个服务器端控件)
  9. 如何让你的前端代码更像HTML5(用语义元素构造html5)

随机推荐

  1. 上接系出名门Android(8) - 控件(View)之T
  2. Android 博客园客户端 (一) 基本界面
  3. Android: 系统默认音量
  4. android 自定义闪退Dialog 收集闪退信息
  5. How to Create QuickAction Dialog in An
  6. android 软件源码
  7. Android照相功能驱动层中HAL的实现(基于OK
  8. android中使用HTTP协议和TCP协议实现上传
  9. Android(安卓)使用动画效果后的控件位置
  10. android IOS webview word document