我的mvc View 布局为null。我如何在 View 内添加脚本。

@{
   Layout = null;
}

@section Scripts{
<script type="text/javascript">

    $(document).ready(function () {
        $('#txtChild1').on('change', function () {
             $("#C1Age1").show();
        });
    });

</script>
}

错误显示

最佳答案

如果您使用Layout = null,则无需再使用@section Scripts。您可以简单地使用脚本标签。

示例:

@{
   Layout = null;
}

<script type="text/javascript">
    $(document).ready(function () {
        $('#txtChild1').on('change', function () {
             $("#C1Age1").show();
        });
    });
</script>

10-02 06:08
查看更多