javascript - Remove input element from cell and preserve the value, when clicked outside of cell or another cell -
i want input elements in cells disappear when click outside of cells or on cell (note clicked cell must active afterwards, have input element). , cell must keep value of input element. when cell clicked, input element must appear (that part solved). html: <table> <tr> <td>content</td> <td>content</td> </tr> <tr> <td>content</td> <td>content</td> </tr> </table> javascript: //this part creates input in td element, allows editing cell content , //when enter pressed removes input leaving cell value (the okay part) $("td").click(function(){ if($(this).find("input").length==0){ var cellcontent = $(this).html(); $(this).empty(); $(this).append("<input type='text' size='"+cellcontent.length+"' value='"+cellcontent+"'>"); ...