jQuery有height()en width()函数,以像素为单位返回高度或宽度...
如何使用jQuery 获取元素的填充或边距值(以像素为单位)和整数?
我的第一个想法是做以下事情:
var padding = parseInt(jQuery("myId").css("padding-top"));
但是,如果在ems中给出填充,例如,我如何获得以像素为单位的值?
查看Chris Pebble建议的JSizes插件,我意识到我自己的版本是正确的:).jQuery总是以像素为单位返回值,因此只需将其解析为整数即可.
感谢Chris Pebble和Ian Robinson
有没有办法将a的宽度缩放<input type="text">到实际值的宽度?
input {
  display: block;
  margin: 20px;
  width: auto;
}<input type="text" value="I've had enough of these damn snakes, on this damn plane!" />
<input type="text" value="me too" />