I use Twitter Bootstrap v 2.0.1 and gave my table a class with a strip. I am trying to change the color of a string if I clicked. This works fine, except for every nth line that does not have a stripe color. I guess I need to remove the striped color first, but my attempt failed. Any idea what I am missing?
HTML
<table class="table table-bordered table-condensed table-striped"> <thead> <tr> <th>Col 1</th> <th>Col 2</th> <th>Col 3</th> </tr> </thead> <tbody> <tr> <td><strong>Data 1</strong></td> <td>Data 2</td> <td>Data 3</td> </tr> <tr> <td><strong>Data 1</strong></td> <td>Data 2</td> <td>Data 3</td> </tr> <tr> <td><strong>Data 1</strong></td> <td>Data 2</td> <td>Data 3</td> </tr> </tbody> </table>
My jQuery attempt:
<script type="text/javascript"> $(document).ready(function(){ $('tr').click( function() { $(this).siblings().removeClass('table-striped'); </script>
What am I doing wrong?
source share