I have a large form that I would like it to check if there are any check boxes that are checked, if there are then open the divs attached to them. I have this working off of an onclick event but it's not working on load. This link is very close but only works off of one checkbox.


Here is the code that I am currently using:

HTML Code:

$('input[class^=toggle]').click(function() {
var $this = $(this);
var x = $this.attr("className");
	if ($('.' + x).is(':checked')){
		$('.open' + x).show(500);
	} else {
		$('.open' + x).hide(500);
This works really well while filling out the form but once they submit it, if there are any errors it takes them back to the form. I have some php written that makes the form sticky but am trying to figure out how to get it to check the checkboxes and if they are checked make the section visible.

Again - Multiple checkboxes to bring up multiple divs. I know how to do it based on id but I need to make it visible using the method I am using to detect classnames.

Let me know if you have any questions.