can this code be shortened??
Hi,
I'm new to JQuery (and javascript in general) and just created the following code which works fine. When a user clicks the #category1 element, certain div elements (itemA..ItemN) are either hidden or shown. Based on what the code is doing, would there be a better (shorthand?) way of writing this code?
Thanks!
-
$(document).ready(function() {
$('#category1').click(function() {
// hide/show relevant divs
$('.itemA').show();
$('.itemB').show();
$('.itemC').hide();
$('.itemD').hide();
$('.itemE').hide();
$('.itemF').hide();
$('.itemG').hide();
$('.itemH').hide();
$('.itemI').show();
$('.itemJ').show();
$('.itemK').hide();
$('.itemL').hide();
$('.itemM').hide();
$('.itemN').hide();
});
});