views:

46

answers:

1

hi I am using a list view for showing selection marks.

 <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>

i am adding css class

.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; 
}

I want to add functionality like if I select another answer as a best answer then previous selected best answer image shuld be change.

How can I do this with jQuery?

I am thinking like

+1  A: 

Maybe you want addClass and removeClass?... these functions have been around since jQuery 1.0.

$('.bestAnswer').click(function(){
 $('.IsBestanswer').removeClass('IsBestanswer');
 $(this).addClass('IsBestanswer');
})
fudgey