For future reference there is also a solution without jQuery - just have the wrapper div style contain overflow:hidden
and use this JavaScript two-liner:
// get the width of the textarea minus scrollbar
var textareaWidth = document.getElementById("textarea").scrollWidth;
// width of our wrapper equals width of the inner part of the textarea
document.getElementById("wrapper").style.width = textareaWidth + "px";
See demo or complete HOWTO.
Update: you can use the same principle to create scrollable div without scrollbar: demo.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…