Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/71.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 扩展/折叠表(一行除外)_Javascript_Jquery_Html - Fatal编程技术网

Javascript 扩展/折叠表(一行除外)

Javascript 扩展/折叠表(一行除外),javascript,jquery,html,Javascript,Jquery,Html,我需要折叠表,除了单击一行。下面的代码完成了这项工作: html: 一旦可见,只有一行希望在鼠标上方展开表格,这也很容易: $("tr").mouseover(function(){ $("tr").show(); }); 那么现在,如何使表重新折叠到mouseout上,使同一行可见 非常感谢您的建议。您应该在活动行中添加一个类,并使用该类确定要显示/隐藏的内容 $("tr").click(function () { $(this) .addClass(

我需要折叠表,除了单击一行。下面的代码完成了这项工作:

html:

一旦可见,只有一行希望在
鼠标上方展开表格,这也很容易:

$("tr").mouseover(function(){
        $("tr").show();
});
那么现在,如何使表重新折叠到
mouseout
上,使同一行可见


非常感谢您的建议。

您应该在活动行中添加一个类,并使用该类确定要显示/隐藏的内容

$("tr").click(function () {
    $(this)
       .addClass('active')
       .siblings()
       .removeClass('active')
       .slideToggle();
});

$(".header").mouseover(function(){
    $("tr").show();
}).mouseout(function(){
    $('tr:not(.active)').hide();
});

您应该向活动行添加一个类,并使用该类确定要显示/隐藏的内容

$("tr").click(function () {
    $(this)
       .addClass('active')
       .siblings()
       .removeClass('active')
       .slideToggle();
});

$(".header").mouseover(function(){
    $("tr").show();
}).mouseout(function(){
    $('tr:not(.active)').hide();
});

感谢@gaby-aka-g-petrioli代码的完美工作,只需在
$(“table”)中将
tr
更改为
table


谢谢。

多亏了@gaby-aka-g-petrioli代码,只需将
tr
更改为
$(“表格”)中的
表格即可。鼠标悬停(function()
允许我更改所选行


谢谢。

对于隐藏的元素,
mouseover()
如何工作?!剩下一行,
mouseover
工作得很好:)对于隐藏的元素,
mouseover()
如何工作?!剩下一行,
mouseover
工作得很好:)
$("tr").click(function () {
    $(this)
       .addClass('active')
       .siblings()
       .removeClass('active')
       .slideToggle();
});

$(".header").mouseover(function(){
    $("tr").show();
}).mouseout(function(){
    $('tr:not(.active)').hide();
});