views:

20

answers:

1

So, I will explain a bit further.

I have a table with different cells. What I need to do is that when the user clicks on the cell, that cell would change its class and highlight. That is working perfect.

The thing is I need is to unhighlight that cell if another cell is clicked.

All cells has the "unselected" class by default. When clicked, class is changed to "unselected selected". Imagine a radioButton, thats the way I need it to work.

$('.unselected').click(function() {
        $("td").find("unselected selected").removeClass("selected");
        $(this).toggleClass("selected", this.clicked);
});

Any clues?

Thanks in advance.

A: 

So, I kept trying and I found the answer, so I'll post the code.

I hope this will help someone in the near future.

$('.unselected').click(function() {
        $("td.unselected.selected").toggleClass("selected");
        $(this).toggleClass("selected", this.clicked);
});
Darklomba