Надеюсь что правильно понял автора
клик.
HTML:
<div class="cells">
<div class="js-cells-elem" data-cellscount="1">1</div>
<div class="js-cells-elem" data-cellscount="2">2</div>
<div class="js-cells-elem" data-cellscount="3">3</div>
<div class="js-cells-elem" data-cellscount="4">4</div>
<div class="js-cells-elem" data-cellscount="5">5</div>
<div class="js-cells-elem" data-cellscount="6">6</div>
</div>
<input type="text" class="js-hidden-input" style="display:none;"/>
CSS:
.cells div {
margin: 1px;
border: solid 1px gray;
width: 40%;
float: left;
height: 30px;
}
JS:
var myTable = $('.cells'),
cellsElem = myTable.find('.js-cells-elem');
cellsElem.on('click', function () {
var $this = $(this),
myText = $this.text(),
myTextId = $this.data('cellscount'),
myInput = $('.js-hidden-input');
myInput.
val(myText).
show().
attr("data-id", myTextId).
focus();
});
$('.js-hidden-input').on('blur', function () {
var $this = $(this),
myInputId = $this.attr('data-id'),
myCells = $('.js-cells-elem').filter('[data-cellscount="' + myInputId + '"]');
myCells.text($this.val());
$this.hide();
});