【发布时间】:2019-10-06 18:48:23
【问题描述】:
试图在 ASP.NET MVC 中检索我的 DropDownList 的选定值。我正在使用以下代码:
HTML
grid.Column("Other", header: "Other", format: @<text>@Html.DropDownList("OtherKey", (IEnumerable<SelectListItem>)ViewBag.OtherKeysList, new { @class = "extra-class" })</text>)))
结果如下:
尝试使用以下代码检索我的 DropDownList 的选定值(在本例中为:otherkey3、otherkey2、otherkey1):
<script type="text/javascript">
var dict = [];
$('#btnSubmit').click(function (e) {
$('#tableID > tbody > tr > td').each(function () {
$('#OtherKey > option').each(function () {
console.log(($(this).val()));
});
});
});
</script>
但这不起作用,我得到以下输出:
有人看到我做错了吗?
提前致谢!
【问题讨论】:
标签: javascript jquery loops drop-down-menu webgrid