我想在td
下一个按钮时向click
标签中添加活动类,并从当前按钮中删除,并且也要对以前的按钮做同样的操作
// functions button
$('button:eq(0)').on('click', () => {
if ($('.one').hasClass('activeQ')) {
$('.one').removeClass('activeQ').next().addClass('activeQ');
$('.active').removeClass('active').next().addClass('active');
} else {
$('.activeQ').removeClass('activeQ').next('.Q').addClass('activeQ');
$('.active').removeClass('active').next().addClass('active')
}
});
$('button:eq(1)').on('click', function() {
if ($('.one').hasClass('activeQ')) {
} else {
$('.activeQ').removeClass('activeQ').prev('.Q').addClass('activeQ');
$('.active').removeClass('active').prev().addClass('active');
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<tr>
<td data-class=".one" class="active">1</td>
<td data-class=".tow">2</td>
<td data-class=".three">3</td>
<td data-class=".four">4</td>
<td data-class=".five">5</td>
</tr>
<tr>
<td data-class=".six">6</td>
<td data-class=".seven">7</td>
<td data-class=".eight">8</td>
<td data-class=".nine">9</td>
<td data-class=".ten">10</td>
</tr>
<tr>