The script only changes the width of the element, it doesn't grow to the right. But as the element is aligned to the left, it will expand to the right.
If you want to grow it to the left, you have to place it in the container and align it to the right.
See example:
<div style="width: 200px; text-align:right">
<input type="text" id="box" style="width: 100px;" />
</div>
http://jsfiddle.net/9SSg3/420/
Gerd K
source
to share