Well, after many changes, I think we will finally come to a solution here. jsFiddle
$(function() {
$('form').jqTransform({
imgPath: 'img/'
});
var jqCheckbox = $('.jqTransformCheckbox');
var maps = $('#map-container AREA');
jqCheckbox.unbind('click');
jqCheckbox.click(function(evt) {
var jqTrans = $(this).toggleClass('jqTransformChecked');
var checkbox = jqTrans.next('input[type=checkbox]');
$('.' + checkbox.prop('id') + '-map').toggleClass('selected');
checkbox.prop('checked', !checkbox.prop('checked'));
});
maps.click(function(evt) {
evt.preventDefault();
var id = $(this).prop('id');
$('.' + id + '-map').toggleClass('selected');
$('.' + id + '-link').toggleClass('jqTransformChecked');
var checkbox = $('input[type=checkbox][id=' + id + ']');
checkbox.prop('checked', !checkbox.prop('checked'));
});
maps.hover(function(evt) {
$('.' + $(this).prop('id') + '-map-hover').toggleClass('selected');
});
$('.form-row label').hover(function(evt) {
var id = $(this).find('input').prop('id');
$('.' + id + '-map-hover').toggleClass('selected');
});
$('.form-row input[type=checkbox]').change(function(evt) {
var map = $('.' + $(this).attr('id') + '-map');
map.toggleClass('selected');
});
});
source
share