Reputation: 10095
i have a repeater control. On clicking the row should set the background color of this or and clicking the another row should unselect the previous selected row. How to do it?
Upvotes: 0
Views: 258
Reputation: 690
You want to be like this?
$('#list li').click(function(){
$(this).addClass('active').siblings().removeClass('active');
});
#list {width:500px;margin:50px auto;}
#list li {margin:10px 0;padding:10px;background:#f0f0f0;color:#000;}
.active {background:#F60 !important;color:#FFF !important;}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<ul id="list">
<li>row1</li>
<li>row2</li>
<li>row3</li>
<li>row4</li>
<li>row5</li>
<li>row6</li>
<li>row7</li>
</ul>
Upvotes: 2