I am trying to use a button as a switch. If I click on the button the value and id changes. If I click on the button again it goes back to original value and id.
Original values could look like this:
value="Show all" id="showall"
Changed to this values
value="Standard" id="default"
<script>
$(function () {
$("#showall").click(function () {
$("#showall") // change the Value text to Standard on the button
$("#showall") // Change ID value to default on the button
});
$("#default").click(function () {
$("#default") // change value back to the original which is "Show all"
$("#default") // change ID back to original which is "Showall"
});
</script>
Assuming this button is within some type of
<div class="container"></div>where we can handle its event (You could handle it from the body, or document as well, though that’s not advised):Demo: http://jsbin.com/eravoq/2/edit