[英]how to access @Html.RadioButtonFor in jquery
i have a coded a radio button in MVC razor.below is the code for it. 我在MVC razor中有一个编码的单选按钮。下面是它的代码。
@{
var LinkRadioName = "_Link";
var ContentRadioName ="_Content";
var TextRadioName = "_Text";
var ExternalLinkRadioName ="_ExternalLink";
var FilelistRadioName ="_Filelist";
@Html.RadioButtonFor(m => m.MenuType, true, new { @id = LinkRadioName })
@Html.Label("Link")
@Html.RadioButtonFor(m => m.MenuType, false, new { @id = ContentRadioName })
@Html.Label("Content")
@Html.RadioButtonFor(m => m.MenuType, true, new { @id = TextRadioName })
@Html.Label("Text")
@Html.RadioButtonFor(m => m.MenuType, false, new { @id = ExternalLinkRadioName })
@Html.Label("External Link")
@Html.RadioButtonFor(m => m.MenuType, true, new { @id = FilelistRadioName })
@Html.Label("File List")
}
can any one help me ,as to how can i access this radiobutton set in jquery: 任何人都可以帮助我,至于我如何访问jquery中设置的此单选按钮:
i have a code like this 我有这样的代码
@Html.RadioButton("TypeOfmenu", 1)Link
@Html.RadioButton("TypeOfmenu", 2)Content
@Html.RadioButton("TypeOfmenu", 3)Text
@Html.RadioButton("TypeOfmenu", 4)ExternalLink
@Html.RadioButton("TypeOfmenu", 5)Filelist
and i access it very easily in jquery like 我很容易在jquery中访问它
$("input[name$='TypeOfmenu']").click(function () {
var Selectedvalue = $(this).val();
});
is there any way to access the @Html.RadioButtonFor control in d same way like 有没有办法以相同的方式访问@ Html.RadioButtonFor控件,如
$("input[name$='MenuType']").click(function () {
var Selectedvalue = $(this).val();
});
?????? ??????
please help me as im very new in MVC as well as jquery. 请帮助我,因为我在MVC和jQuery中非常新。
Since you are accessing the values in your function with this.val()
, you can just bind your event to all radio buttons 由于您正在使用
this.val()
访问函数中的值,因此您可以将事件绑定到所有单选按钮
$(":radio").click(function () {
var Selectedvalue = $(this).val();
//OR
//var Selectedvalue = this.value;
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.