Jquery..单击另一个表格单元格后,单元格文本未重新显示

Jquery... Cell text not re-displaying after I click on another table cell

本文关键字:单元格 新显示 显示 文本 另一个 单击 表格 Jquery      更新时间:2023-09-26

我有一张桌子。 它通过PHP显示来自MySQL的数据

我正在使用jquery从用户那里动态获取数据。

当用户单击单元格时:1.单元格文本显示"无"2.选中单元格中的复选框

3.显示供用户输入的输入文本字段

当用户单击关闭单元格(例如到另一个单元格)时,我想要:1.复选框取消选中自身2.输入文本字段消失3.和单元格文本重新显示

除了 3.要重新显示的单元格文本外,我让它们都正常工作。我需要在用户单击另一个单元格时显示单元格的原始文本

           $('#table9 tr td').click(function(){
        var $this = $(this);
    //checks checkbox of cell by default
    $this.children('input').prop('checked', true);
    //makes sure that checkboxes in other cells are not checked
    $this.siblings().children('input').prop('checked', false);
    $this.parent('tr').siblings().children('td').children('input').prop('checked', false);
    //hides current text in cell if cell is clicked
    $('span' , this).css('display','none');

    //displays a text field for input
    $this.children('.hiddenjqside').css('display' , 'inline');
    //hides input text field if user should click on another cell
    $this.siblings().children('.hiddenjqside').css('display' , 'none');
    $this.parent('tr').siblings().children('td').children('.hiddenjqside').css('display', 'none');

    //display the text of the current cell when user click another cell
    $('span' , this).siblings().css('display' , 'inline'); <---------NOT WORKING!!!!!!!!!!!!!!
我想

你想做:

$this.siblings().find('span').css('display' , 'inline');

或使用上下文:

$('span' , $this.siblings()).css('display' , 'inline');

此外,您还可以通过使用hide()show()而不是手动更改css display属性来节省自己的一些键入

好的,

我想通了...我可能没有清楚地说明问题。 以下是我所做的。

$this.siblings().children('span').css('display' , 'inline');
    $this.parent('tr').siblings().children('td').children('span').css('display' ,       'inline');