I need assistance with changing the value of a td
when a specific button is clicked. I have attempted various methods but none seem to be working. Ideally, I want the column to display only USD
values when the "Show USD" button is clicked, and display only GBP
values when the "GBP" button is clicked. I'm unsure if my current approach is correct or not. Any help would be greatly appreciated.
$('.btn-usd').on('click', function(){
$("cu-usd").removeClass(hide);
$("cu-gbp").addClass(hide);
});
$('.btn-gbp').on('click', function(){
$("cu-gbp").removeClass(hide);
$("cu-usd").addClass(hide);
});
.hide {
display: none;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="btn-usd">show USD</div>
<div class="btn-gbp">show GBP</div>
<table>
<tbody>
<tr>
<td>
<div class="cu-usd">$10</div>
<div class="cu-gbp">£7.10</div>
</td>
<td>
<div class="cu-usd">$20</div>
<div class="cu-gbp">£14.20</div>
</td>
<td>
<div class="cu-usd">$30</div>
<div class="cu-gbp">£21.30</div>
</td>
<td>
<div class="cu-usd">$40</div>
<div class="cu-gbp">£28.10</div>
</td>
</tr>
</tbody>
</table>
<table>
<tbody>
<tr>
<td>
<div class="cu-usd">$100</div>
<div class="cu-gbp">£70.10</div>
</td>
<td>
<div class="cu-usd">$200</div>
<div class="cu-gbp">£140.20</div>
</td>
<td>
<div class="cu-usd">$300</div>
<div class="cu-gbp">£210.30</div>
</td>
<td>
<div class="cu-usd">$400</div>
<div class="cu-gbp">£280.10</div>
</td>
</tr>
</tbody>
</table>