JQuery 实现多个checkbox 只选中一个
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | <! DOCTYPE HTML> < html > < head > < meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> < meta name = "viewport" content = "user-scalable=no, width=device-width"> < meta name="apple-mobile-web-app-capable" content="yes" /> < title >JQuery 实现多个checkbox 只选中一个</ title > < meta name="author" content="geovindu,塗聚文,Geovin Du" /> < script src="Scripts/jquery.min.js" type="text/javascript"></ script > </ head > < body > < script type="text/javascript"> $(function() { $('#common-form').find('input[type=checkbox]').bind('click', function(){ var id = $(this).attr("id"); //当前的checkbox是否选中 if(this.checked){ //除当前的checkbox其他的都不选中 $("#common-form").find('input[type=checkbox]').not(this).attr("checked", false); //选中的checkbox数量 var selectleng = $("input[type='checkbox']:checked").length; console.log("选中的checkbox数量"+selectleng); } else{ //未选中的处理 console.log("未选中的处理"); } }); }) //http://9bitstudios.github.io/flexisel/ //https://github.com/9bitStudios/flexisel/ </ script > < form id="common-form"> < input name="H1" type="checkbox"/>check1 < input name="H2" type="checkbox"/>check2 < input name="H3" type="checkbox"/>check3 </ form > < form id="form1" name="form1" class="form1" method="post" action="SaveReQuestTickets.aspx?Action=Add&ProjectID=23"> < input name="H1" type="checkbox" id="H1" value="1"/>check1 < input name="H2" type="checkbox" id="H2" value="2"/>check2 < input name="H3" type="checkbox" id="H3" value="3"/>check3 </ form > < script type="text/javascript"> $(function() { $("#form1").find('input[type=checkbox]').bind('click', function(){ var id = $(this).attr("id"); //当前的checkbox是否选中 if(this.checked){ //除当前的checkbox其他的都不选中 $("#form1").find('input[type=checkbox]').not(this).attr("checked", false); //选中的checkbox数量 var selectleng = $("input[type='checkbox']:checked").length; console.log("选中的checkbox数量"+selectleng); } else { //未选中的处理 console.log("未选中的处理"); } }); }) </ script > </ body > </ html > |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | <! DOCTYPE HTML> < html > < head > < meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> < meta name = "viewport" content = "user-scalable=no, width=device-width"> < meta name="apple-mobile-web-app-capable" content="yes" /> < title >Flexisel - A responsive jQuery Carousel</ title > < meta name="author" content="geovindu,塗聚文,Geovin Du" /> < link href="css/style.css" rel="stylesheet" type="text/css" /> < script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js"></ script > < script type="text/javascript" src="js/jquery.flexisel.js"></ script > </ head > < body > < h1 >Flexisel</ h1 > < p >Flexisel will adapt responsively as the screen width gets smaller...</ p > < ul id="flexiselDemo1"> < li >< img src="images/logo-nyt.png" /></ li > < li >< img src="images/logo-microsoft.png" /></ li > < li >< img src="images/logo-ebay.png" /></ li > < li >< img src="images/logo-hp.png" /></ li > < li >< img src="images/logo-youtube.png" /></ li > </ ul > < div class="clearout"></ div > < p >You can also change the number of items shown depending on the screen width.</ p > < ul id="flexiselDemo2"> < li >< img src="images/logo-adidas.png" /></ li > < li >< img src="images/logo-nike.png" /></ li > < li >< img src="images/logo-amazon.png" /></ li > < li >< img src="images/logo-spotify.png" /></ li > < li >< img src="images/logo-android.png" /></ li > </ ul > < div class="clearout"></ div > < p >Other options include autoplay, number of items to scroll, animation speed when scrolling right and left, initial number of visible items, and more!</ p > < ul id="flexiselDemo3"> < li >< img src="images/1.jpg" /></ li > < li >< img src="images/2.jpg" /></ li > < li >< img src="images/3.jpg" /></ li > < li >< img src="images/4.jpg" /></ li > </ ul > < div class="clearout"></ div > < p >And you can set whether you want the slider to be infinite or not.</ p > < ul id="flexiselDemo4"> < li >< img src="images/chevrolet.png" /></ li > < li >< img src="images/ford.png" /></ li > < li >< img src="images/aston-martin.png" /></ li > < li >< img src="images/mini.png" /></ li > < li >< img src="images/lamborghini.png" /></ li > < li >< img src="images/ferrari.png" /></ li > </ ul > < script type="text/javascript"> //http://9bitstudios.github.io/flexisel/ //https://github.com/9bitStudios/flexisel/ $(window).load(function() { $("#flexiselDemo1").flexisel(); $("#flexiselDemo2").flexisel({ visibleItems: 4, itemsToScroll: 3, animationSpeed: 200, infinite: true, navigationTargetSelector: null, autoPlay: { enable: true, interval: 5000, pauseOnHover: true }, responsiveBreakpoints: { portrait: { changePoint:480, visibleItems: 1, itemsToScroll: 1 }, landscape: { changePoint:640, visibleItems: 2, itemsToScroll: 2 }, tablet: { changePoint:768, visibleItems: 3, itemsToScroll: 3 } }, loaded: function(object) { console.log('Slider loaded...'); }, before: function(object){ console.log('Before transition...'); }, after: function(object) { console.log('After transition...'); }, resize: function(object){ console.log('After resize...'); } }); $("#flexiselDemo3").flexisel({ visibleItems: 5, //显示多少个图片 itemsToScroll: 1, animationSpeed: 400, infinite: true, navigationTargetSelector: null, autoPlay: { enable: true, interval: 5000, pauseOnHover: true }, responsiveBreakpoints: { portrait: { changePoint:480, visibleItems: 1, itemsToScroll: 1 }, landscape: { changePoint:640, visibleItems: 2, itemsToScroll: 2 }, tablet: { changePoint:768, visibleItems: 3, itemsToScroll: 3 } } }); $("#flexiselDemo4").flexisel({ infinite: false }); }); </ script > </ body > </ html > |
哲学管理(学)人生, 文学艺术生活, 自动(计算机学)物理(学)工作, 生物(学)化学逆境, 历史(学)测绘(学)时间, 经济(学)数学金钱(理财), 心理(学)医学情绪, 诗词美容情感, 美学建筑(学)家园, 解构建构(分析)整合学习, 智商情商(IQ、EQ)运筹(学)生存.---Geovin Du(涂聚文)
分类:
Ajax&JavaScript
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 零经验选手,Compose 一天开发一款小游戏!
· 一起来玩mcp_server_sqlite,让AI帮你做增删改查!!
2012-05-10 csharp Format CultureInfo