你需要使用
change
,不是
ifChanged
$('#chk_change_pass').on('change', function() {
if ($(this).is(':checked')) {
$('[name=password]')
.prop('disabled', false);
}
else {
$('[name=password]')
.prop('disabled', true);
}
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<form data-parsley-validate>
<input type="checkbox" id="chk_change_pass">
<input type="password" name="password" data-parsley-excluded="[disabled]" disabled >
<input type="submit">
</form>
<script src="https://cdnjs.cloudflare.com/ajax/libs/parsley.js/2.8.1/parsley.min.js"></script>