1
1、獲取的當(dāng)前輸入的代碼長度
2、一個(gè)單選框,默認(rèn)選中,再次點(diǎn)擊不選。
js:
function cha(){ var curLength=$("#newmsg").val().length; $("#textCount1").text($("#newmsg").val().length); } $(function(){ var isChecked = true; $('#alt').click(function(){ if(isChecked){ $(this).removeAttr('checked'); }else{ $(this).attr('checked',true); } isChecked = !isChecked; }); });
html的代碼:
1 <!--方法1對應(yīng)的html--> 2 <div> 3 <b>字?jǐn)?shù):<span id="textCount1"/></b> 6 <textarea name="newtext" id="textMsg" cols="45" rows="4" onkeyup="cha();" /> 7 </div> 8 9 <!--方法2對應(yīng)的html-->
10 <input type="hidden" name="alt" value="2" /> 11 <label> 12 <input name="alt" type="radio" value="1" id="alt" checked/> 13 <b>單選框</b> 14 </label> 15
java 中代碼:
int alt= Integer.parseInt(request.getParameter("alt"));//獲取是否選中,然后根據(jù)業(yè)務(wù) 做具體判斷
浙公網(wǎng)安備 33010602011771號