1 <br/>2 <input name="radio" type="radio" checked="checked" value="男"/>男3 <input name="radio" type="radio" value="女"/>女4 <br/><br/><br/>5 <label id="message">哈哈哈哈</label>
然后在JS中代碼如下:
1 <script type="text/javascript"> 2 $(function(){ 3 $("input[name='radio']").click(function() { 4 if($(this).val() == "男") { 5 $("#message").show(); 6 } else{ 7 $("#message").hide(); 8 } 9 }); 10 })11 </script>
form表單中radiobuttons的基本設置如下:
1 <form:radiobuttons path="isall" items="${fns:getDictList('allType')}"2 itemLabel="label" itemValue="value"3 htmlEscape="false" class="" onclick=""/>
這里沒有顯式的給出radio的name和type,要去渠道這兩個屬性只需要在網頁上查看源代碼,就可以得到它的屬性,然后編寫JS即可:
1 $(function () { 2 3 $("input[name='isall']").click(function () { 4 if ($(this).val() == "0") { 5 $("#usermsg").hide(); 6 } else { 7 $("#usermsg").show(); 8 } 9 }); 10 });
我這里的操作是根據選中值的情況來顯示或隱藏一部分頁面,將需要顯示或隱藏的部分的style設置為display:none即可,如:
1 <p id="usermsg" class="control-group" style="display: none"> 2 <label class="control-label">用戶賬號:</label> 3 4 <p class="controls"> 5 <input id="user_id" type="text" maxlength="100" name="userId" class="input-medium"/> 6 <shiro:hasPermission name="doctor:doctormsgpush:edit"> 7 <input type="submit" value="查詢用戶ID" onclick="check()" 8 class="btn btn-primary"/> 9 </shiro:hasPermission>10 </p>11 </p>
聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com