0

I use the table plug-in for jquery Datatable at my rails app, and i look for a way to delete the whole column if some actions occurs e.g. if a button was clicked.

The table:

<table id="words" class="display" data-source="<%= url_for controller:"words", action: "index", :format=>:json %>" >
<thead>
    <tr>
      <th><%= l(:name) %></th>
       .
       .
       .
    </tr>
</thead>
<tbody>    
</tbody>
</table>

How can I do that?

2

1 Answer 1

1

Ok, nth-child selector works(thx @TrueBlueAussie) for my the following way:

$('#words thead').find("tr th:nth-child(5)").each(function(){$(this).remove()});
$('#words tbody').find("tr td:nth-child(5)").each(function(){$(this).remove()});

It removes the 5'th column from my table.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.