There was a similar question that partially solved my issue, but I'm wondering if using class
or id
NAMES instead of ul li
- such as .menu
, #menu
, etc. would work in this scenario.
CSS:
div { display:none; background:red; width:200px; height:200px; }
JS:
$(function() {
$('ul li').each(function() {
$(this).click(function(e) {
var i = $(this).index();
$('div').hide();
$('div:eq('+i+')').show();
});
});
});
Here is the jsfiddle link for reference: http://jsfiddle.net/Z3Hj7/
I apologize if this question seems trivial, but I've been struggling with it and can't seem to find a solution.