input box with ellipsis - jquery
by pj_js15
HTML
<div class="long-value-input-container">
<input type="text" class="long-value-input" value="sdghkjsdghhjdfgjhdjghjdfhghjhgkdfgjnfkdgnjkndfgjknk" readonly />
</div>
CSS
.long-value-input {
width: 150px;
height: 30px;
padding: 0 10px;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
}
JavaScript
// making the input editable
$('.long-value-input').on('click', function() {
$(this).prop('readonly', '');
$(this).focus();
})
// making the input readonly
$('.long-value-input').on('blur', function() {
$(this).prop('readonly', 'readonly');
});