[英]Jquery on selected dropdownlist item show a hidden div tag
I want to show a hidden div tag when i select a comparative question.我想在 select 比较问题时显示隐藏的 div 标签。 My code for the drop down list is as follows:
我的下拉列表代码如下:
<%=Html.DropDownList("QuestionType", new List<SelectListItem>
{
new SelectListItem{Text="Standard", Value = "1"},
new SelectListItem{Text="Custom", Value = "2"},
new SelectListItem{Text="Demographic", Value = "3"},
new SelectListItem{Text="Ranking", Value = "4"},
new SelectListItem{Text="Comparative", Value = "5"}
}) %>
My code for my hidden div tag:我的隐藏 div 标签代码:
<!--Create Comparative Question Partial View-->
<div id="divCreateComparativeQuestion">
<% Html.RenderPartial("CreateComparativeQuestion"); %>
</div>
So when the user clicks on comparative question from the drop down list, I want to go something like所以当用户从下拉列表中点击比较问题时,我想 go 类似
$('#divCreateComparativeQuestion').show();
$('#divCreateComparativeQuestion :input').removeAttr('disabled');
How would i go about achieving this?我将如何实现这一目标? Thanks guys!
多谢你们!
Basically what you've already got.基本上你已经得到了什么。 Just hook into the
change
event of the dropdownlist.只需挂钩下拉列表的
change
事件。
$(function() {
$('#yourdropdown').change(function() {
$('#divCreateComparativeQuestion').show();
});
});
No need to remove the disabled attribute - as that's what show()
does anyway.无需删除 disabled 属性 - 无论如何,这就是
show()
所做的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.