šířka inputu automatická

by Petr Haluza

HTML

<input type="text" value="1" />

<input type="text" value="123456" />

CSS

input {
 display: block;
 margin: 20px;
 width: auto;
 font-family: serif;
}

JavaScript

function resizeInput() {
    $(this).attr('size', $(this).val().length);
}

$('input[type="text"]')
    // event handler
    .keyup(resizeInput)
    // resize on page load
    .each(resizeInput);