单击按钮时,我正在尝试更改按钮的类别。为什么我的不工作:看我的小提琴
HTML:
<button id="repeatMon" onclick="changeStyle()"><span> Mon </span></button>
<br/>
<button id="repeatTues" data-bind="checked: repeatTues" onclick="changeStyle()"><span> Tues </span></button>
<br/>
<button id="repeatWeds" data-bind="checked: repeatWeds" onclick="changeStyle()"><span> Weds </span></button>
<br/>
<button id="repeatThurs" data-bind="checked: repeatThurs" onclick="changeStyle()"><span> Thurs </span></button>
<br/>
<button id="repeatFri" data-bind="checked: repeatFri" onclick="changeStyle()"><span> Fri </span></button>
<br/>
<button id="repeatSat" data-bind="checked: repeatSat" onclick="changeStyle()"><span> Sat </span></button>
<br/>
<button id="repeatSun" data-bind="checked: repeatSun" onclick="changeStyle()"><span> Sun </span></button>
<br/>
CSS:
button{
width: 60px;
height: 35px;
border-radius: 0px;
color: #cfcfcf;
background: #0a4a58;
}
.active{
color: #fff;
background: ##02AEFF;
}
jQuery:
function changeStyle(){
$(this).toggleClass('active');
}
谢谢你!