Demo - http://jsfiddle.net/P9rs6/
HTML
<span class="js-make-input" data-id="1" data-value="5">5</span>
jQuery
$('.js-make-input').on('dblclick', function(){
var itemID = $(this).attr('data-id');
var value = $(this).attr('data-value');
$(this).attr('class', 'js-edit-row');
$(this).html(' <input type="text" value="' + value + '" data-id="' + itemID + '" style="width: 45px" /> ');
});
$('.js-edit-row').on('dblclick', function(){
$(this).attr('class', 'js-make-input');
$(this).html(value);
var value = $(this).attr('data-value', value);
});
I can understand, why it doesn't work after second dblclick.