I did (.a input) auto increase width, when user type.
But now i don’t know how to make (.b) at same time auto move to right? avoid overlapping
Thank you in advance.
if ($a.width()"+1px"){
$b.animate({
left: "+1px"
}, 1000 );
};
html css
<input class="a" value="texttext">
<input class="b" value="texttext">
.a{
position: absolute;
left: 10px;
top: 22px;
width: 100px;
font-size: 19px;
}
.b{
position: absolute;
left: 110px;
top: 22px;
width: 100px;
font-size: 19px;
}
I think you need a different approach to this problem. You need to hook to the
keyupevent ofinput.aand get the text width as you’re typing the text. However, you cannot get the width of the text by normal means so you would need to employ some sort of cloned div to be updated withinput.a‘s text every time you type:P.S.: my fiddle has the clone div shown. If you want to hide it, do not use
display:noneas the browser wouldn’t able to calculate it’s width if it’s hidden, instead just position it outside of the viewport usingtop:-9999px;left:-9999px;in CSS.