溫馨提示×

jq js為這個@Html.TextBoxFor賦值

js
小云
125
2023-08-18 14:58:32
欄目: 編程語言

可以使用以下代碼為@Html.TextBoxFor賦值:

  1. 使用jQuery的.val()方法:
$("#TextBoxId").val("賦值內(nèi)容");

其中,"TextBoxId"是@Html.TextBoxFor的id屬性。

  1. 使用JavaScript原生方式:
document.getElementById("TextBoxId").value = "賦值內(nèi)容";

同樣,"TextBoxId"是@Html.TextBoxFor的id屬性。

注意:以上代碼需要在DOM加載完成后執(zhí)行,可以放在$(document).ready()事件中或者放在頁面底部。

0