我正在尝试使用jQuery计算文本宽度.我不确定是什么,但我肯定做错了什么.
所以,这是代码:
var c = $('.calltoaction');
var cTxt = c.text();
var cWidth = cTxt.outerWidth();
c.css('width' , cWidth);
Run Code Online (Sandbox Code Playgroud) 有没有办法将a的宽度缩放<input type="text">到实际值的宽度?
input {
display: block;
margin: 20px;
width: auto;
}Run Code Online (Sandbox Code Playgroud)
<input type="text" value="I've had enough of these damn snakes, on this damn plane!" />
<input type="text" value="me too" />Run Code Online (Sandbox Code Playgroud)