单击按钮时显示div标签

时间:2013-06-01 05:04:35

标签: javascript razor

页面加载时,下面的div标签应该是隐藏的。单击按钮时应显示div。我使用的是asp.net mvc razor

<div id="field">
        @Html.LabelFor(model => model.createSetting.Name)
        @Html.TextBoxFor(model =>model.createSetting.Name, new { @class = "span6 m-wrap" })
        @Html.ValidationMessageFor(model => model.createSetting.Name)

        @Html.LabelFor(model => model.createSetting.ExternalCode)
        @Html.TextBoxFor(model =>model.createSetting.ExternalCode, new { @class = "span6 m-wrap"})
        @Html.ValidationMessageFor(model => model.createSetting.ExternalCode)
</div>
<input type="button" value="Add Setting" id="btnAddSetting" class="btn green"/>

1 个答案:

答案 0 :(得分:1)

将您的div设置为最初隐藏:

<div id="field" style="display:none;">

然后使用JQuery,添加click事件以显示div:

<input onclick="javascript:$('#field').show();" .... />