我有八个单选按钮,我从数据库中获取它们的值。 我想在更改事件
上显示“指标”字段控制器:
ViewBag.indicator = db.Info.ToList();
return View();
查看:
@if (ViewBag.indicator != null)
{
foreach (var ind in ViewBag.indicator)
{
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-12">
<input name="indicator" type="radio" id="@ind.id" value="@ind.ID" class="radio-col-blue-grey" />
<label for="@ind.ID">@ind.Indicator</label>
</div>
}
}
Jquery的:
$("input[name=indicator]:radio").change(function () {
var info = $('input[name=indicator]:checked').val();
alert(info);
});