I have 3 sets of Divs
1 set with 4 'boxes'.
1 set with 2 'boxes'.
1 set with 2 'boxes'.
What I'm after is a way of clicking one div on each set and having them change it different colour to indicate that they have been clicked, I found some sample code which works for the first set, but not the other 2 (It only allows 1 div to be selected at any one time). Here is the code and I wondered what would need to be changed to accommodate what I'm after.
1 set with 4 'boxes'.
1 set with 2 'boxes'.
1 set with 2 'boxes'.
What I'm after is a way of clicking one div on each set and having them change it different colour to indicate that they have been clicked, I found some sample code which works for the first set, but not the other 2 (It only allows 1 div to be selected at any one time). Here is the code and I wondered what would need to be changed to accommodate what I'm after.
Code:
var highlightLink = function () {
var active = null, colour = '#CC9900';
if (this.attachEvent) this.attachEvent('onunload', function () {
active = null;
});
return function (element) {
if ((active != element) && element.style) {
if (active) active.style.backgroundColor = '#999999';
element.style.backgroundColor = colour;
active = element;
}
};
}();