I have the following HTML generated dynamically by PHP. When I click active, it changed to inactive and vise versa.
I added div class='status' for jquery manipulation. (Do I need it? Can I do it without this div?)
I want to change CSS class='status' to class='inactive' when I click active and when I click inactive changing CSS class to 'active' as well, so that I can change a color or add bg image etc.
HTML
...
...
<tr valign='top'>
<td align='center'>21</td>
<td>Kontakt</td>
<td>/kontakt.html</td>
<td align='center'>
<div class="status">
<a href="http://127.0.0.1/ci/index.php/admin/pages/changePageStatus/21">active</a>
</div>
</td>
<td align='center'>...
...
</td>
</tr>
I am using jquery and I need some guidance.
Can anyone tell me some jquery code please?
--UPDATE--
There are many div with calss='status', so how can I tell jquery that I want to change the css which I clicked.
--UPDATE 2--
I want to check the value(active/inactive). And add it's value as class. e.x If its value is active, then add css class='active' and if it is inactive then class='inactive' etc. Can I do it? Or you have other suggestions how I should do it.
--UPDATE 3--
Thanks everyone. You guys rock. I tested some of codes. But the problem is that when I click active, it change the bg, but then refreshes the page to change to inactive via php/mysql. So this means each time I click the value(active/inactive) changes. So I think as I stated in update 2, it might be good idea to add css class depends on the value. More suggestions are welcome and I appreciate them. (I have not done it with AJAX yet...)
--UPDATE 4 --
Using ID is not a good idea since the table is created dynamically. I can add IDs but it will add more code. So I thought class is better.
--UPDATE 5--
I moved my question here. http://stackoverflow.com/questions/1909223/how-to-add-a-class-depends-on-value-with-jquery
After this, I now know what I want to do.