how can i change the background of an element in the array?


Possible Duplicate:
i want to change the background color after clicking?

how can i change the background of an item in the table ?

and when the mouse is over any item it's color changed so i used that CSS code:

         background-color: #EFF2F7;

that's fine so to change the background color of the clicked item i used this little java-script code

function getclick(elem)
{ = '#EFF2F7';

So i want now if i clicked other item the previous item return it's default color which is white and the next item change and the hover in css keep working that's like the facebook left menu...

for more details this is the code i had written

You can add css class with your custom style (instead of explicitly setting background color) to those elements and then modify your function like:

function getclick(elem)
//find any elemenet with given class
//remove that class from it
//add that class to 'elem'

I don't know correct syntax in pure javascript, but with jQuery, it could be:

// find any element with given class and remove it
// add that class to clicked element

You can see working example here.
Btw: Your example didn't work for me.