In my menu, I have these items:
<ul>
<li class="menu_item" data-content_id="#landscape_context">Landscape Context</li>
<li class="menu_item" data-content_id="#terrestrial_features">Terrestrial Features</li>
<li class="menu_item" data-content_id="#aquatic_features">Aquatic Features</li>
<li class="menu_item" data-content_id="#vegetaion_land_use">Vegetation/Land Use</li>
<li class="menu_item" data-content_id="#additional_features">Additional Features</li>
<li class="menu_item" data-content_id="#data_descriptions">Data Descriptions</li>
<li class="menu_item" data-content_id="#faq">FAQ</li>
</ul>
Then when a user clicks on one of the items, I want to show the content for that data-content_id. However, nothing is happening when I click.
Here is the javascript:
$(".menu_item").click(function () {
alert("Hello");
});
I've replaced the code with the simple alert which also does not show up when I click on a menu item.
I've looked at numerous of the other examples found here on SO, but couldn't find anything different about my solution.
Anybody see what I might be doing wrong here?
Thanks
$(document).ready(function() {...});so that it executes after the DOM has loaded and the elements exist. Take a look at this page of the documentation for more information.$(document).ready(function() { .. });block? Are thelielements dynamically appended?.live()function has been deprecated since version 1.7. Using that instead of simple jQuery practices makes no sense.