gpt4 book ai didi

html - 如果复选框未选中,则禁用按钮

转载 作者:行者123 更新时间:2023-12-01 09:41:50 26 4
gpt4 key购买 nike

我有一个带有复选框和按钮的 Angular 组件,如果未选中该复选框,则应禁用该按钮。
什么是正确的方法?

<div class="form-check my-5">
<input type="checkbox" class="form-check-input id="agreements">
<label class="form-check-label" for="agreements">I have signed the agreements</label>
</div>

<button type="button" class="btn btn-outline-danger">Continue</button>

最佳答案

使用带有一个标志的 [disabled] 属性。

component.html

<div class="form-check my-5">
<input type="checkbox" class="form-check-input" [(ngModel)]="isDisabled" id="remember-me" name="rememberMe">
<label class="form-check-label" for="remember-me">I have signed the agreements</label>
</div>

<button type="button" [disabled]="!isDisabled" class="btn btn-outline-danger">Continue</button>

component.ts
isDisabled: boolean = false;

这将解决您的问题..

关于html - 如果复选框未选中,则禁用按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59409741/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com