javascript - 在asp应用程序中使用jquery隐藏字段

标签 javascript jquery html asp.net .net

我有一个 asp.net mvc4 应用程序,我需要一些本期的应用程序:

<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css"/>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css"/>
<script>
    $(function () {
        $(".datepicker").datepicker();
    });

</script>
</head>
<br/><br/>
<center><strong style="color:red; font-size:x-large">Réserver une véhicule</strong></center>
<br/><br/>
<form action="/User/Reserver" method="post" style="margin-left: 33%; ">
    <div>
        <strong style="color:blue">L'affaire de la réservation </strong>
        <div>
            <SELECT style="" name="id_affaire">
            @for(int item =0; item < Model[0].Count; item++){
                <OPTION VALUE="@Model[0][item].Id_affaire">@Model[0][item].Affaire_description</OPTION>
            }
            </SELECT>
        </div>
        <br/> <br/>
    </div>
    <div>
        <strong style="color:blue">Le matricule de véhicule </strong>
        <div>
            <SELECT style="" name="matricule">
            @for(int item =0; item < Model[1].Count; item++){
                <OPTION VALUE="@Model[1][item].Id_vehicule">@Model[1][item].Matricule</OPTION>
            }
            </SELECT>
        </div>

    </div>
    <br/><br/>

    <div>
        <input type="radio" name="choix" id="plus" value="Plus d'un jour" style=" margin-left:0px; width: 30px" checked>
        <strong style="color:black ">Plus d'un jour</strong>
        <br/>
        <div><strong style="color:blue ">Nombre de jours</strong></div>
        <div><input type="text" name="nbr_jours"/></div>
        <br/>
        <div>
            <strong style="color:blue ">A partir de </strong>
            <div>
                <input type="text" class="datepicker" name="date" value="" style=""/>
            </div>
        </div>
    </div>
    <br/>

    <div>
        <input type="radio" name="choix" id="un" value="un jour" style=" margin-left:0px; width: 30px">
        <strong style="color:black ">Un jour</strong>
        <br/>
        <div>
            <strong style="color:blue ">Le : </strong>
            <div>
                <input type="text" class="datepicker" name="date" value="" style=""/>
            </div>
        </div>
    </div>
    <br/>
    <div>
        <input type="radio" name="choix" id="periode" value="une periode" style=" margin-left:0px; width: 30px">
        <strong style="color:black ">Une période</strong>
        <br/> <strong style="color:blue">La période </strong>
        <div>
            <SELECT style="" name="periode">
                <OPTION VALUE="1">Matinale</OPTION>
                <OPTION VALUE="2">Aprés Midi</OPTION>
            </SELECT>
        </div>
    </div>

    <div>
        <strong style="color:blue ">Jour </strong>
        <div>
            <input type="text" class="datepicker" name="date" value="" style=""/>
        </div>
    </div>
    <br/>
    <div><input type="submit" value="Reserver" name="btn" style="color:black"/></div>
</form>

我需要fadeinfadeout当我检查单选框时的输入元素:例如,如果我检查 <input type="radio" name="choix" id="plus" value="Plus d'un jour" style=" margin-left:0px; width: 30px" checked> div 中的所有输入下面将被隐藏。

我怎样才能用jquery做到这一点?

最佳答案

$('input[name="choix"]').on('click', function(){
    var $this = $(this),
    allinputs = $this.parent().find('input:not("' + $this + '")');
    if($this.is(':checked')) allinputs.fadeOut(300);
    else allinputs.fadeIn(300);
});

关于javascript - 在asp应用程序中使用jquery隐藏字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18352814/

相关文章:

javascript - 找不到汇总模块 : Error: Can't resolve 'jquery'

javascript - 添加行后编辑时剑道网格行消失

javascript - 如果图片处于事件状态,则更改图片,如果不活动,则更改回来

javascript - 动态更改网站中的单词

Javascript html函数输入按钮输出

javascript - 使用 D3.js 在美国 map 中定义区域

javascript - 点击功能上的简单 Jquery 动画位置

javascript - jQuery 只能读取一次选择选项?

javascript - 将 HTML 类添加到由 two.js 控制的 DOM 元素

javascript - 使用 math.random() 在 jquery 中为 div 设置动画;