有沒有辦法根據布爾變數使輸入可見?
<input type="button" value="Smth" onclick="...">
我正在嘗試為此目的找到一個 HTML 幫助程式,但是到目前為止還沒有運氣。
uj5u.com熱心網友回復:
input您可以使用運算子實作將欄位設定為禁用所需的結果ternary conditional:
<input type="button" value="Smth" onclick="..." @(myBoolCondition == "true" ? "disabled='disabled'" : "") >
你的變數在哪里myBoolCondition保存你的條件結果。
uj5u.com熱心網友回復:
嘗試這個
@if ( your bool condition)
{
<input type="button" value="Smth" onclick="..."> //visible
}
else
{
<input type="button" class="d-none" value="Smth" onclick="..."> //none-visible
//or
<input type="button" hidden value="Smth" onclick="...">
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/452684.html
標籤:C# html 网 。网 asp.net-mvc
上一篇:通過外部網頁處理請求
