Hi, I have a lot of buttons and by clicking on different button, different image and text would appear. I can achieve what I want, but the code is just so long and it seems very repetitive. For example:
var aaClick = false;
$("aa").observe('click', function() {
unclick();
$('characterPic').writeAttribute('src',"aa.jpg");
$('characterBio').update("aatext");
$('aa').setStyle({ color: '#FFFFFF' });
aaClick = true;
});
$("aa").observe('mouseover', function() {
if (!aaClick) $('aa').setStyle({ color: '#FFFFFF' });
});
$("aa").observe('mouseout', function() {
if (!aaClick) $('aa').setStyle({ color: '#666666' });
});
function unclick() {
aaClick = false;
$('aa').setStyle({ color: '#666666' });
}
same thing with bb, cc, etc. and every time I add a new button, I need to add it to unclick function as well. This is pretty annoying and I tried to google it, and I only found observe click on all listed items, so I still couldn't figure out since what I want involves button up when other buttons are clicked.
Is there any way to just have a generic function that takes different id but do the exact same thing? Because from what I can see, if I can just replace aa with other id, I can reduce a lot of code. Thanks!!!