I have a table structure, something similar to
<table style="width: 100%;">
<tr>
<td>
<a href="#" class="xx">one</a>
</td>
<td>
</tr>
<tr>
<td>
<a href="#" class="xx">Two</a>
</td>
<td>
</tr>
<tr>
<td>
<a href="#" class="xx">Three</a>
</td>
<td>
</tr>
</table>
css:
.xx {
border: 5px solid green;
}
.yy {
border: 5px solid red;
}
Now what I expect is, if I click on 1st row/1st <a> its border will turn to red, and rest of <a> in green, again if I clcik on 1st row/1st <a> it should turn to green. Also if I click on any other <a> then only it should turn to red, but rest of the <a> should be green.
I tried:
$(function () {
$("a.xx").click(function () {
if ($(this).hasClass("xx")) {
$(this).removeClass("xx").addClass("yy");
} else {
$(this).removeClass("yy").addClass("xx");
}
});
});
But it's not working.