Excel數(shù)字顯示E+18怎么恢復(fù)正常
5810
2023-11-18
1、問題背景
有幾個多選框,選擇其中的幾個,獲取選中的值
2、設(shè)計結(jié)果如下圖所示:
3、設(shè)計源碼
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>jQuery獲取checkbox選中的值</title> <script type="text/javascript" src="http://www.gimoo.net/t/1903/jquery-2.2.0.js"></script> <script type="text/javascript"> $(function(){ $("input[name='ckb']:checkbox").click(function() { var str = ""; $("input[name='ckb']:checkbox").each(function() { if($(this).is(":checked")) { str += $(this).attr("value")+","; } }); if(str != null && str.length > 1) { str = str.substring(0,str.length-1); } alert(str); }); }); </script> </head> <body> <input type="checkbox" name="ckb" value="1"/>蘋果 <input type="checkbox" name="ckb" value="2"/>橘子 <input type="checkbox" name="ckb" value="3"/>梨子 <input type="checkbox" name="ckb" value="4"/>香蕉 </body> </html>
下面給大家分享一段代碼關(guān)于jQuery操作CheckBox的方法(選中,取消,取值)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE> New document.nbsp;</TITLE> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <SCRIPT LANGUAGE="javascript" src="http://www.cnjquery.com/demo/jquery.js"></script> <SCRIPT LANGUAGE="javascript"> < $("document.quot;).ready(function(){ $("#btn1").click(function(){ $("[name='checkbox']").attr("checked",'true');//全選 }) $("#btn2").click(function(){ $("[name='checkbox']").removeAttr("checked");//取消全選 }) $("#btn3").click(function(){ $("[name='checkbox']:even").attr("checked",'true');//選中所有奇數(shù) }) $("#btn4").click(function(){ $("[name='checkbox']").each(function(){ if($(this).attr("checked")) { $(this).removeAttr("checked"); } else { $(this).attr("checked",'true'); } }) }) $("#btn5").click(function(){ var str=""; $("[name='checkbox'][checked]").each(function(){ str+=$(this).val()+""r"n"; //alert($(this).val()); }) alert(str); }) }) //--> </SCRIPT> </HEAD> <BODY> <form name="form1" method="post" action=""> <input type="button" id="btn1" value="全選"> <input type="button" id="btn2" value="取消全選"> <input type="button" id="btn3" value="選中所有奇數(shù)"> <input type="button" id="btn4" value="反選"> <input type="button" id="btn5" value="獲得選中的所有值"> <br> <input type="checkbox" name="checkbox" value="checkbox1"> checkbox1 <input type="checkbox" name="checkbox" value="checkbox2"> checkbox2 <input type="checkbox" name="checkbox" value="checkbox3"> checkbox3 <input type="checkbox" name="checkbox" value="checkbox4"> checkbox4 <input type="checkbox" name="checkbox" value="checkbox5"> checkbox5 <input type="checkbox" name="checkbox" value="checkbox6"> checkbox6 <input type="checkbox" name="checkbox" value="checkbox7"> checkbox7 <input type="checkbox" name="checkbox" value="checkbox8"> checkbox8 </form>
以上所述是小編給大家分享的jQuery獲取checkbox選中的值,希望對大家有所幫助。
#免責(zé)聲明#
本站[綠夏技術(shù)導(dǎo)航]提供的一切軟件、教程和內(nèi)容信息僅限用于學(xué)習(xí)和研究目的;不得將上述內(nèi)容用于商業(yè)或者非法用途,否則,一切后果請用戶自負。本站信息來自網(wǎng)絡(luò)收集整理,版權(quán)爭議與本站無關(guān)。您必須在下載后的24個小時之內(nèi),從您的電腦或手機中徹底刪除上述內(nèi)容。如果您喜歡該程序或內(nèi)容,請支持正版,購買注冊,得到更好的正版服務(wù)。我們非常重視版權(quán)問題,如有侵權(quán)請郵件[admin@lxwl520.com]與我們聯(lián)系進行刪除處理。敬請諒解!