I use the sub class to perform on click the submit of the parent form. I would try to enable / disable the button dinamically. I tried in this way, but even if I remove dinamically the sub class action submit remains active
HTML
<form action="foo.php" method="post">
<div id="btn_src" class="bttn sub">CLICK ME</div>
</form>
CSS
.bttn {
width: 100px;
border: 1px solid #ccc;
text-align: center;
}
.sub {
background: red;
}
.disabled {
background: grey;
}
JS
$('.bttn.sub').on('click', function() {
var form = $(this).closest('form');
$(form).submit();
});
var disab_btn = function() {
$('#btn_src').removeClass('sub').addClass('disabled');
alert($('#btn_src').attr('class'));
}
var enab_btn = function() {
$('#btn_src').removeClass('disabled').addClass('sub');
alert($('#btn_src').attr('class'));
}
disab_btn();
Then I tried removing the sub class from html, but in this case the submit action is always disabled.
<form action="foo.php" method="post">
<div id="btn_src" class="bttn">CLICK ME</div>
</form>
how can I do it? Thanks
disabledproperty?disab_btnat all!disabledproperty makes more sense; but that's your call and dictated by your use-case.