A little problem with toggleClass
I'm having a little problem with toggle class here:
https://jsfiddle.net/sxnk6jwr/13/
if you click 1 and 3, the first td cell's highlight will switch from orange to gray.
I'd appreciate a little help to solve this issue, please. thanks.
here is jquery:
- $(function(){
- $('#btn1').on('click', function() {
- $('#tb1 td').slice(0, 3)
- .toggleClass('orange');
- });
- $('#btn2').on('click', function() {
- $('#tb1 td').slice(3, 6)
- .toggleClass('orange');
- });
-
- $('#btn3').on('click', function() {
- $("#tb1 tr:gt(-7):lt(3) td:nth-child(1)").toggleClass('orange');
- });
-
- $('#btn4').on('click', function() {
- $("#tb1 tr:gt(2):lt(6) td:nth-child(1)").toggleClass('orange');
- });
-
- });
- $(".button").click(function(){
- $(this).toggleClass("active");
- });