我有三个按钮,并且想在被选中时更改按钮的颜色。As you will see, I am able to change the color on selection, but I need buttonA to return to its original color when buttonB is selected (at which point buttonB should take on the selected color) and so on. 目前,每个选定的按钮都采用选定的颜色,但按钮不会恢复到其原始颜色。
请看这个小提琴:http: //jsfiddle.net/Fwqv8/
这是脚本:
jQuery(document).ready(function(){
jQuery('button.account').click(function() {
jQuery(this).removeClass("account");
jQuery(this).addClass("btn-success");
});
});
理想情况下,当页面最初加载时,会有一个默认按钮 (buttonA) 具有选定的颜色。
帮助将不胜感激。谢谢你。