Skip to content

How do I grab the checked value on init? #223

Description

@cmcguff-myob

I have some code on changing the checkbox that toggles some UI on/off, that piece is working fine per this code

$('input[name="leave_type[validate_balance]"]').change(function() {
	$('#threshold_options').toggle($(this).prop('checked'));
});

If I try and grab the value on init, it is always false, no matter what's been saved, how do I get the state of the checkbox on first load? Everything else works perfectly.

$('input[name="leave_type[validate_balance]"]').init(function() {
    // Always false
    alert($('input[name="leave_type[validate_balance]"]').prop('checked'));
});

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions