I'm new to jQuery and am having a hard time trying to get something very simple to work. I have the following basic html:
first I have a list of buttons
<div id="my_menu">
<ul>
<li><a href="" class='1'">Link 1</a></li>
<li><a href="" class='2'">Link 2</a></li>
<li><a href="" class='3'">Link 3</a></li>
</ul>
</div>
Then I have some divs:
<div id="ref_1">Message 1</div>
<div id="ref_2">Message 2</div>
<div id="ref_3">Message 3</div>
Now I simply want to click a link and show the appropriate message while hiding the others.
First, I set the default message and link state:
$(document).ready(function(){
$('#ref_1').show();
$('#ref_1').siblings('div').hide();
$('#my_menu li a.1).parent('li').addClass("active");
});
So far, so good. Next, I try to setup the click events on the list
$("#my_menu li a").click(function(){
alert('you have a click event');
return false;
});
I can't get a click event. I also tried:
$("#my_menu li").each( function(){
alert('you have a click event');
return false;
});
});
Can anyone see where I'm going wrong?