Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/377.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 有没有办法做一个<;td>;当选择按钮且<;td>;显示为无?(<;td>;将有一个codeMirror文本区域)_Javascript_Html_Html Table - Fatal编程技术网

Javascript 有没有办法做一个<;td>;当选择按钮且<;td>;显示为无?(<;td>;将有一个codeMirror文本区域)

Javascript 有没有办法做一个<;td>;当选择按钮且<;td>;显示为无?(<;td>;将有一个codeMirror文本区域),javascript,html,html-table,Javascript,Html,Html Table,我这里有点麻烦。我正在开发一个按钮,一旦选中该按钮,它将运行一个JavaScript函数ShowColumn(),该函数将显示一个表列。表格列将首先隐藏-“显示:无;”-但一旦用户选择按钮,隐藏的表格列将显示/将可见。但是,此表列将有一个codeMirror文本区域。这能做到吗?如果是的话,有人能帮忙吗?谢谢:) 我已将我迄今为止所做的工作包括如下: .隐藏{ 显示:无; } .可见{ 显示:块; } 函数ShowColumn(){ document.getElementById(“列”).

我这里有点麻烦。我正在开发一个按钮,一旦选中该按钮,它将运行一个JavaScript函数ShowColumn(),该函数将显示一个表列。表格列将首先隐藏-“显示:无;”-但一旦用户选择按钮,隐藏的表格列将显示/将可见。但是,此表列将有一个codeMirror文本区域。这能做到吗?如果是的话,有人能帮忙吗?谢谢:)

我已将我迄今为止所做的工作包括如下:


.隐藏{
显示:无;
}
.可见{
显示:块;
}
函数ShowColumn(){
document.getElementById(“列”).className=“可见”;
}
.CodeMirror{
边界:无;
宽度:100%;
身高:451px;
左边距:100;
}
点击我
一些css代码将在这里。。。。
index.html
另一个_page.html
占位符页面.html
other.html
var editor=CodeMirror.fromTextArea(document.getElementById(“code2”){
行号:对,
是的,
模式:“文本/css”,
换行:对,
主题:'默认',
});
一些css代码将在这里。。。。
index.html
另一个_page.html
占位符页面.html
other.html
var editor=CodeMirror.fromTextArea(document.getElementById(“code2”){
行号:对,
是的,
模式:“文本/css”,
换行:对,
主题:'默认',
});

使用JQuery管理样式和编写此类代码更容易:

$('#hiddenColumn').show();
$('#hiddenColumn').hide();
不要忘记隐藏第二列中的所有单元格

您可以在此处看到一个示例:
JQuery具有显示、隐藏和切换功能,可帮助您实现所需功能。最初,使用class=hide隐藏表列。使用toggle()函数,可以在按下按钮时显示/隐藏它

小提琴:

参考:


希望这有帮助

jQuery.show()和.hide()工作得很好,但我不确定为什么您所拥有的不起作用?这就是jQuery、CSS和DOM操纵诞生的原因。您好,感谢您的快速响应:)什么是DOM操纵?你能告诉我如何将它合并到我的代码中吗?谢谢你们的帮助!感谢@godmode,每当我使用jQuery.show()和/或.hide()时,表列中的内容都是隐藏的,而不是实际的表列本身。有什么建议吗?感谢@MartinDonies的回复,我想知道您是否可以将您的编码魔法付诸实践,以帮助我找到上述新(编辑)问题的新答案。谢谢你的帮助谢谢男人-@GobSmack,我想知道你是否有空给我?@R.Jones:对不起,伙计,我有点忙。但是如果你需要帮助,请把我放在这里!嘿@GobSmack-我想知道你是否可以看看我的这个新问题:-它链接到这个更具体的当前问题-谢谢:)嗨@GobSmack-我很抱歉再次打扰你,但请你看看我发布的这个新问题-我似乎找不到答案。但是我确信你可以用你的wizzing技能来变戏法-谢谢
 <body>
    <button onclick="ShowTable()">Display Table</button>
    <button onclick="ShowColumn()">Display Column</button>

    <table id="hiddenTable" class='show'>
      <tr>
         <td>
           <textarea>Write something here....</textarea>
         </td>
        <td id="hiddenColumn" class='hide'>
           <textarea>Write something here....</textarea>
         </td>
      </tr>
    </table>  

      <script type="text/Javascript">

      function ShowColumn()
      {  
            $("#hiddenColumn").toggle();
      }

      function ShowTable()
      {
            $("#hiddenTable").toggle();
      }
    </script>
</body>
var cm = $('.CodeMirror')[0].CodeMirror;

//Hide
$(cm.getWrapperElement()).hide();

//Show
$(cm.getWrapperElement()).show();