Mission: To use checkboxes to toggle divs. Inputs 1 and 2 control the same div $("input[type=checkbox]").click(function(){ divClass = $(this).attr("class"); if ($(this).is(":checked")) { $("#" + divClass).show(); } else if($(this).not(":checked")) { $("#" + divClass).hide(); } });
Input 1: Controls div 1
Input 2: Controls div 1
Input 3: Controls div 2
Input 4: Controls div 3
Input 5: Controls div 4
Controlled by Input 1 or 2

Controlled by Input 3

Controlled by Input 4

Controlled by Input 5