我想用一个按钮作为开关。如果我点击按钮value
和id
的变化。如果我再次点击该按钮,它会回到原来的value
和id
。点击按钮更改按钮上的ID值,点击新的ID改回原来的ID与Jquery
原始值可能看起来像这样:
value="Show all" id="showall"
更改为此值
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>
你应该切换改变ID的类代替。 – jbabey