【发布时间】:2020-06-14 02:29:05
【问题描述】:
我有一个看板,用户可以在其中更改状态或将其设置为优先级
这是我的 html(如果有例如 10 个任务,则此 html 重复多次,则此代码将重复 10 次。)
<form method="post">
<p style="padding:0px;margin:0px">
<b>Etapa:</b>
@Html.DropDownListFor(x => lv_task.contrato_etapa_id, new SelectList(lv_task.etapas, "etapa_id", "nombre_etapa"), htmlAttributes: new { @id="drEtapa", @class = "form-control-kanban-popup-dropdown", @required = "required" })
</p>
<p style="padding:0px;margin:0px">
<label class="checkbox-text">
Prioridad
@Html.CheckBoxFor(x=>lv_task.contract_details.prioritario)
<span class="checkmark"></span>
</label>
</p>
<button id="@lv_task.contract_number">Actualizar y cerrar ventanilla</button>
</form>
到目前为止,这是我的 jquery
$(document).ready(function () {
$("button").click(function (e) {
e.preventDefault();
$.ajax({
type: "POST",
url: "/kanban/salvarEstado",
data: {
id_etapa: $('#drEtapa').val(),
prioridad: $('#chkPrioridad').val()
},
success: function (result) {
alert('ok');
},
error: function (result) {
alert('error');
}
});
});
});
我的问题是下面的代码总是正确的
$('#chkPrioridad').val()
我正在使用来自 w3school 的自定义复选框,可以在此处找到 https://www.w3schools.com/howto/tryit.asp?filename=tryhow_css_custom_checkbox
选中复选框时更改的代码如下
<span class="checkmark"></span> //NOT CHECKED
<span class="checkmark"> //IS CHECKED
::after
</span>
任何帮助将不胜感激,谢谢。
【问题讨论】:
-
这能回答你的问题吗? checkbox is always "on"
-
@RajeshG 不,我没有尝试过,但它对我不起作用,因为我没有正常的复选框 我有一个定制的复选框,其中唯一改变的是 ::after in跨度
标签: jquery asp.net-mvc