Removing columns, row counting

I have the following installation example

http://jsfiddle.net/gibble/srBeB/

What I'm trying to do is delete the first two columns of the table

The problem is that the first column contains cells with rowspan='2'

So when I delete it, go to the next line, it will delete the cell which should not

Thoughts on how to make this work?

+4
source share
1 answer

Since the strings are involved, you have to change your strategy. Your table has four columns, so instead of deleting the first two columns, you should strive to keep only the last two.

This can be easily achieved by passing a negative upper bound to slice () :

 $(this).children("td, th").slice(0, -2).remove(); 

Here you will find an updated script.

+1
source

Source: https://habr.com/ru/post/1384143/


All Articles