This question is regarding the Highlighting of ListItems.
I am highlighting the list items by using following classes.
ul.category_list li {
background: none repeat scroll 0 0 #B73737;
border-bottom: 1px solid #CCCCCC;
color: #953131;
display: block;
height: 29px;
width: 242px;
}
ul.category_list li a:link,ul.category_list a:visited {
display: block; width: 227px; height: 18px; padding: 5px 0 6px 15px;
background: #fff; text-decoration: none; color: #666; }
ul.category_list li a:hover {
display: block; width: 227px; height: 18px; padding: 5px 0 6px 15px;
background: #e5e5e5 url(../images/disc_apps/nav_over.jpg) no-repeat; text-decoration: none; color: #666; }
ul.category_list li a:active {
display: block; width: 227px; height: 18px; padding: 5px 0 6px 15px;
background: #e5e5e5; text-decoration: none; color: #666; }
Please refer this working example at http://jsfiddle.net/XMbAS/
Now, i want that, the clicked element should stay highlighted unless i click other element.Currently it is not happening. please help me with that.If anything is possible with jquery then please let me know.
thank you
I changed your demo here:
http://jsfiddle.net/XMbAS/2/
Edit: This is just a straightforward and simple solution using CSS class. First you reset all elements with that class, and then you add it to clicked list element from your specific list.
Edit: Demo with hover included:
http://jsfiddle.net/balron/XMbAS/7/
In my script, I am only adding and removing one class, so all hover definitions should still work without problems. It all about CSS after all. Sorry for not doing it on your code, but I gave up trying to copy paste.. SO is really missing some copy with whitespace included. Also the jsfiddle wasn’t listening to me when I was trying to modify your example.