嗨我正在使用列表视图来显示选择标记。
<asp:listview id="lvanswerlist" runat="server">
<layouttemplate>
</layouttemplate>
<itemtemplate>
<asp:Panel ID="Idanswercontent" CssClass="answer" runat="server">
<div class="bestAnswerControl">
<div id="divBestAnswer" class="bestAnswer" runat="server">
<%-- best answer control goes here --%>
</div>
<asp:HiddenField ID = "hfObjectID" runat="server" />
<asp:HiddenField ID = "hfIsBestanswer" runat="server" />
<asp:HiddenField ID = "hfQuestionId" runat = "server" />
</div>
<asp:/panel>
</itemtemplate>
<asp:/listview>
我正在添加css类
.bestAnswer
{
background-image:url('contrl/Vote/Images/before_accept2.png');
background-repeat:no-repeat;
cursor:pointer;
height:35px;
width: 35px;
margin-left: 24px;
}
/*.bestAnswer:hover
{
background-position: 0 100%;
}*/
.IsBestanswer
{
background-image:url('control/Vote/Images/after_accept.png');
background-repeat:no-repeat;
cursor:pointer;
height: 38px;
width: 38px;
margin-left: 24px;
}
我想添加一些功能,如果我选择另一个答案作为最佳答案,那么之前选择的最佳答案图片应该更改。
如何使用jQuery执行此操作?
我在想
答案 0 :(得分:1)
也许你想要addClass
和removeClass
?...这些函数自jQuery 1.0以来一直存在。
$('.bestAnswer').click(function(){
$('.IsBestanswer').removeClass('IsBestanswer');
$(this).addClass('IsBestanswer');
})