I'm kinda new at this jQuery stuff and I've gathered up this much to make my code functional, but I would really want to shorten it. I've already tried $('#Monday','#Tuesday'....) to group them, but with no success.
$('#Monday').click(function() {
if ($(this).hasClass("active")){
$(this).switchClass( "active", "inactive", 200, "easeInOutQuad" );
$(this).parent().find('.miniTime').prop('disabled', true);
} else {
$(this).switchClass( "inactive", "active", 200, "easeInOutQuad" );
$(this).parent().find('.miniTime').prop('disabled', false);
}
$(this).find('input').prop('checked', function( foo, oldValue ) {return !oldValue});
});
$('#Tuesday').click(function() {
if ($(this).hasClass("active")){
$(this).switchClass( "active", "inactive", 200, "easeInOutQuad" );
$(this).parent().find('.miniTime').prop('disabled', true);
} else {
$(this).switchClass( "inactive", "active", 200, "easeInOutQuad" );
$(this).parent().find('.miniTime').prop('disabled', false);
}
$(this).find('input').prop('checked', function( foo, oldValue ) {return !oldValue});
});
$('#Wednesday').click(function() {
if ($(this).hasClass("active")){
$(this).switchClass( "active", "inactive", 200, "easeInOutQuad" );
$(this).parent().find('.miniTime').prop('disabled', true);
} else {
$(this).switchClass( "inactive", "active", 200, "easeInOutQuad" );
$(this).parent().find('.miniTime').prop('disabled', false);
}
$(this).find('input').prop('checked', function( foo, oldValue ) {return !oldValue});
});
$('#Thursday').click(function() {
if ($(this).hasClass("active")){
$(this).switchClass( "active", "inactive", 200, "easeInOutQuad" );
$(this).parent().find('.miniTime').prop('disabled', true);
} else {
$(this).switchClass( "inactive", "active", 200, "easeInOutQuad" );
$(this).parent().find('.miniTime').prop('disabled', false);
}
$(this).find('input').prop('checked', function( foo, oldValue ) {return !oldValue});
});
$('#Friday').click(function() {
if ($(this).hasClass("active")){
$(this).switchClass( "active", "inactive", 200, "easeInOutQuad" );
$(this).parent().find('.miniTime').prop('disabled', true);
} else {
$(this).switchClass( "inactive", "active", 200, "easeInOutQuad" );
$(this).parent().find('.miniTime').prop('disabled', false);
}
$(this).find('input').prop('checked', function( foo, oldValue ) {return !oldValue});
});
$('#Saturday').click(function() {
if ($(this).hasClass("active")){
$(this).switchClass( "active", "inactive", 200, "easeInOutQuad" );
$(this).parent().find('.miniTime').prop('disabled', true);
} else {
$(this).switchClass( "inactive", "active", 200, "easeInOutQuad" );
$(this).parent().find('.miniTime').prop('disabled', false);
}
$(this).find('input').prop('checked', function( foo, oldValue ) {return !oldValue});
});
$('#Sunday').click(function() {
if ($(this).hasClass("active")){
$(this).switchClass( "active", "inactive", 200, "easeInOutQuad" );
$(this).parent().find('.miniTime').prop('disabled', true);
} else {
$(this).switchClass( "inactive", "active", 200, "easeInOutQuad" );
$(this).parent().find('.miniTime').prop('disabled', false);
}
$(this).find('input').prop('checked', function( foo, oldValue ) {return !oldValue});
});
click()
calls have indentical contents, why not just have ONE$('#Sunday, #Monday, #Tuesday, #blahblahbhal').click(...)
call? \$\endgroup\$$('#Monday','#Tuesday'....)
to group them, but that has a syntax error. There should only be one set of single quotes around the whole thing like Marc B suggests. \$\endgroup\$