Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/447.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/2/jquery/87.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 Jquery在表行中的两个类之间切换_Javascript_Jquery_Html_Css - Fatal编程技术网

Javascript Jquery在表行中的两个类之间切换

Javascript Jquery在表行中的两个类之间切换,javascript,jquery,html,css,Javascript,Jquery,Html,Css,我使用它来包含一个切换,在两个css类之间切换:twotablecell和tablecell,这两个类是两个不同大小的表头单元格,在css中大小不同 当单击我的按钮id:sizeTog时,它会将table headers类属性更改为tablecell,但再次单击时不会将其更改回twotablecell $('sizeTog')。在('click',function()上{ $('table thead tr.twotablecell').toggleClass(“twotablecell tab

我使用它来包含一个切换,在两个css类之间切换:twotablecell和tablecell,这两个类是两个不同大小的表头单元格,在css中大小不同

当单击我的按钮id:
sizeTog
时,它会将table headers类属性更改为
tablecell
,但再次单击时不会将其更改回
twotablecell

$('sizeTog')。在('click',function()上{
$('table thead tr.twotablecell').toggleClass(“twotablecell tablecell”);
});

名称
我已尝试将需要切换的元素更改为:
table thead tr.two tablecell
,以使其更具体

只有当我将jquerytoggled元素更改为
表thead trth
时,它才会相应地工作


但是,这是因为我有很多不同的表头列,我希望它们的大小不同于
twotablecell
tablecell

,问题是,在第二次单击时,您要查找的元素不再具有
.twotablecell
类-第一次单击将其删除

通过其他方式选择它,使用未删除的其他类,例如:

$('sizeTog')。在('click',function()上{
$('table thead tr.headercell').toggleClass(“twotablecell tablecell”);
});
.tablecell{color:#C00;}
.twotablecell{color:#0C0;}

名称

那么他的页面中的每个
th
都会受到影响吗?不,只有
.headercell