I need to create navigation that shows / hides multiple divs.
Here is what I need to be able to do: If a user clicks on any of the \"options
You should use data attributes, as just target
is'nt really valid. I changed it to data-target
and did:
$('.showSingle').on('click', function () {
$(this).addClass('selected').siblings().removeClass('selected');
$('.targetDiv').hide();
$('#div' + $(this).data('target')).show();
});
FIDDLE
on()
will only work in jQuery 1.7+, so if using an older version of jQuery (your fiddle is), stick with click()
.