作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个 @htmlDropDownList
作为
@Html.DropDownList("MyList", new SelectList(Model.List, "Id", "Movie"))
在 mvc3 View 中。
如何使用 javascript 捕获此下拉列表的选定值,并使用它根据选定项更改 View 的内容?
最佳答案
获取值很简单:
$('#MyList').val()
对于问题的第二部分,我需要更多信息。
更新
我们将如何使用该值?
//get the url for the movie description , define id as 0, so it is easier to replace lateron.
var moviedescriptionUrl = '@Url.Action("details", "movies", new { id = 0})';
//get the movieid
var movieID = $('#MyList').val();
//update a div
$('#movie-description').load(moviedescriptionUrl.replace('0', movieID));
假设我有一个返回部分 View 的“详细信息”操作。
关于javascript - 如何获取@htmlDropDownList 选中的值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4944657/
我有一个 @htmlDropDownList 作为 @Html.DropDownList("MyList", new SelectList(Model.List, "Id", "Movie")) 在
我是一名优秀的程序员,十分优秀!