Lucas₇₅₅
Screw the rules, I have green hair!
- Pronoun
- he
I'm trying to make a dropdown menu. I've got the scripting right for making the menu appear when you click an arrow, but how can I make it so clicking that same arrow again calls a different function? Here's my code:
Basically, showCMenu works when I click the image, but I need to know how to make the onClick function change after that to call hideCMenu. Any ideas?
HTML:
<html>
<head>
<script type="text/javascript">
function showCMenu(menuId) {
document.getElementById(menuId).style.display = 'block';
}
function hideCMenu(menuId) {
document.getElementById(menuId).style.display = 'none';
}
</script>
</head>
<body>
<div id="menu">
<ul>
<li><img src="images/arrow.png" onClick="showCMenu('cmenu1')"><a href="#"></a></li>
<div id="cmenu1">
<a href="#">ipsum</a>
<a href="#">dolor</a>
<a href="#">sit</a>
<a href="#">amet</a>
</div>
</div>
</body>
</html>
Basically, showCMenu works when I click the image, but I need to know how to make the onClick function change after that to call hideCMenu. Any ideas?