I have list of 10 input with disabled property like this
<form method="post" action="" autocomplete="off" class="rule-form">
<div class="form-row">
<div class="form-group col-md-10">
<input type="text" name="rule" class="form-control alert-info" value="First Rule" disabled>
</div>
<div class="form-group col-md-1">
<input type="text" name="point" class="form-control alert-success" value="10" disabled>
</div>
<div class="form-group col-md-1">
<button type="button" class="rule-btn" data-id="1" data-poin="10">Edit</button>
</div>
</div>
<div class="form-row">
<div class="form-group col-md-10">
<input type="text" name="rule" class="form-control alert-info" value="Second Rule" disabled>
</div>
<div class="form-group col-md-1">
<input type="text" name="point" class="form-control alert-success" value="20" disabled>
</div>
<div class="form-group col-md-1">
<button type="button" class="rule-btn" data-id="2" data-poin="20">Edit</button>
</div>
</div>
</form>
When I click Edit button, I want to remove disabled property and alert class for input which is same row with that button. I have tried like this
$('form.rule-form').find('button.rule-btn').each(function(){
$(this).click(function(){
$(this).text('Submit');
$('form.rule-form').find('input[name="rule"]').each(function(){
$(this).prop('disabled', false).toggleClass('alert-info');
});
$('form.rule-form').find('input[name="point"]').each(function(){
$(this).prop('disabled', false).toggleClass('alert-success');
});
$(this).click(function(){
$('form.rule-form').submit();
})
});
});
but it seems all of input list are enabled after I click Edit button.