Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/453.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/80.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 JS/HTML-.SlideToggle两个相邻的表_Javascript_Html_Html Table_Slidetoggle - Fatal编程技术网

Javascript JS/HTML-.SlideToggle两个相邻的表

Javascript JS/HTML-.SlideToggle两个相邻的表,javascript,html,html-table,slidetoggle,Javascript,Html,Html Table,Slidetoggle,我有两张不同高度的桌子挨在一起。我希望桌子能独立滑动切换 选择表格标题时,当前未发生任何操作 小提琴: 欢迎评论 HTML: <h1>Test Heading 1</h1> <table> <tr> <td valign="top"> <table class="tableSort"> <thead> <tr>

我有两张不同高度的桌子挨在一起。我希望桌子能独立滑动切换

选择表格标题时,当前未发生任何操作

小提琴:

欢迎评论

HTML:

<h1>Test Heading 1</h1>
<table>
<tr>
    <td valign="top">
        <table class="tableSort">
            <thead>
                <tr>
                    <th id="clientClick" colspan="3" style="cursor:pointer;">Client</th>
                </tr>
            </thead>
            <div id="clientResult">
                <tr>
                    <td>1</td>
                    <td>2</td>
                    <td>3</td>
                </tr>
                <tr>
                    <td>1</td>
                    <td>2</td>
                    <td>3</td>
                </tr>
            </div>
        </table>
    </td>
    <td valign="top">
        <table class="tableSort">
            <thead>
                <tr>
                    <th id="employeeClick" colspan="3" style="cursor:pointer;">Employee</th>
                </tr>
            </thead>
            <div id="employeeResult">
                <tr>
                    <td>1</td>
                    <td>2</td>
                    <td>3</td>
                </tr>
                <tr>
                    <td>1</td>
                    <td>2</td>
                    <td>3</td>
                </tr>
                <tr>
                    <td>1</td>
                    <td>2</td>
                    <td>3</td>
                </tr>
            </div>
        </table>
    </td>
</tr>
</table>
一个非常糟糕的html和js

  • 不能将tr标记包装到div中
  • 您不需要调用document.ready函数两次
  • 下面是一个适合您的示例的快速jsfiddle。需要改进(没有时间了,对不起)


    不知道为什么会被否决?我对这一点相当陌生,我的解释还不够充分吗?霍洛夫谢谢你的回答。不是“很糟糕”,因为我离得很近不客气。尝试使用google inspector进行调试。这会有很大帮助
    var j$ = jQuery.noConflict();
    
    j$(document).ready(function () {
    j$("#clientClick").click(function () {
        j$("#clientResult").slideToggle(600);
    });
    });
    
    j$(document).ready(function () {
    j$("#employeeClick").click(function () {
        j$("#employeeResult").slideToggle(600);
    });
    });
    
    $(document).ready(function () {
        $("#clientClick").click(function () {
            $("#clientResult").slideToggle(600);
        });
        $("#employeeClick").click(function () {
            $("#employeeResult").slideToggle(600);
        });
    });