I have a couple bits of code that seem like they could be condensed but I’m not sure how.
The code I have is this
var checkForUnitReferred = function () {
$("#LeadForm").toggle($("#Claim_UnitReferredNoNull").is(":checked"));
};
checkForUnitReferred();
$("#Claim_UnitReferredNoNull").change(function() {
checkForUnitReferred();
});
It basically checks if a checkbox is checked and displays a form, otherwise it hides it. What I would rather have is something like this
var checkForUnitReferred = (function() {
$("#LeadForm").toggle($("#Claim_UnitReferredNoNull").is(":checked"));
})();
$("#Claim_UnitReferredNoNull").change(function() {
checkForUnitReferred();
});
I know this doesn’t work but I think something like that would be cleaner. Anyone know of a way to accomplish this?
How about this:
This is possible because the assignment (
=) operator returns the value set.