Jquery 从dropdownlist获取值并在UrlHelper中使用值
我想试试这样的东西,但这是不允许的Jquery 从dropdownlist获取值并在UrlHelper中使用值,jquery,asp.net-mvc,Jquery,Asp.net Mvc,我想试试这样的东西,但这是不允许的 function GetDynamicModulesProperties() { var selectedValue = $("#moduletype option:selected").val(); if (selectedValue.lenght() > 0) { var url = '<%= Url.Action("GetModuleProperties", new { sectionid = ViewDat
function GetDynamicModulesProperties() {
var selectedValue = $("#moduletype option:selected").val();
if (selectedValue.lenght() > 0) {
var url = '<%= Url.Action("GetModuleProperties", new { sectionid = ViewData.Model.Id, moduleTypeId = selectedValue } ) %>';
var renderContainer = $("#modulesettings");
$.get(url, function(data) {
renderContainer.html(data);
renderContainer.fadeIn('slow');
});
}
}
有没有办法做到这一点
Thanx提前在select上执行val以获取所选选项值
var selectedValue = $("#moduletype").val();
要从选项中获取它,您可以使用以下选项,但额外的按键没有意义:
var selectedValue = $("#moduletype>option:selected").attr('value');