用jquery将复选框改成单选框
前提是要包含jquery文件。
相关代码:
jQuery(function($) {
init_price_checkbox("by_price");
init_price_checkbox("by_size");
});
function init_price_checkbox(id){
$("#"+id+" input[type='checkbox']").each(function(){
$(this).click(function(){
for (var i = $("#"+id+" input[type='checkbox']").length - 1; i >= 0; i--) {
if($(this).index("#"+id+" input[type='checkbox']")==i)
$(this).attr('checked','checked');
else
$("#"+id+" input[type='checkbox']").eq(i).removeAttr('checked');
};
});
});
}
html代码:
<div id="by_price">
<form id="search_by_price" method="post" action="index.php?action=search&orderby=price">
<span class="by_words">By Price</span>
<div class="p_left_columu">
<div><input type="checkbox" name="75" value="1" ><span>Under $75</span></div>
<div><input type="checkbox" name="75-100" value="2" ><span>$75 - $100</span></div>
<div><input type="checkbox" name="100-125" value="3" ><span>$100 - $125</span></div>
</div>
<div class="p_right_columu">
<div><input type="checkbox" name="125-150" value="1" ><span>$125 - $150</span></div>
<div><input type="checkbox" name="150" value="2" ><span>$150 & Above</span></div>
</div>
<div class="search_button"><input type="image" border="0" onmouseout="this.src='/themes/diy_html5/images/crystal_by_price/price_search.png'" onmouseover="this.src='/themes/diy_html5/images/crystal_by_price/price_search_on.png'" src="/themes/diy_html5/images/crystal_by_price/price_search.png">
</div>
</form>
</div>
用jquery将复选框改成单选框的更多相关文章
- PHP下拉框内容随单选框内容变化
这久在修改一个项目的小东西,要求把下拉框改为单选框,由于代码封闭,修改不了获取函数,所以想了个办法让下拉框的内容随单选框的内容变化,下面把代码分享给大家: <!DOCTYPE html PUBL ...
- jQuery操作复选框checkbox技巧总结 ---- 设置选中、取消选中、获取被选中的值、判断是否选中等
转载:https://blog.csdn.net/chenchunlin526/article/details/77448168 jQuery操作复选框checkbox技巧总结 --- 设置选中.取消 ...
- 对jquery操作复选框
摘要:jquery操作复选框.使用更简洁易懂,思路清晰,逻辑更明了,很实用 <!DOCTYPE html> <html> <head> <meta chars ...
- jQuery取复选框值、下拉列表里面的属性值、取单选按钮的属性值、全选按钮、JSON存储、*去空格
1.jquery取复选框的值<!--引入jquery包--> <script src="../jquery-1.11.2.min.js"></scri ...
- jquery判断复选框checkbox是否被选中
jquery判断复选框checkbox是否被选中 使用is方法 //如果选中返回true //如果未选中返回false .is(':checked');
- jquery判断复选框是否选中
jquery判断复选框是否被选中 $(function(){ $(document).on("click", ".checkbox",function(){ v ...
- jQuery判断复选框checkbox的选中状态
通过jQuery设置复选框为选中状态 复选框 <input type="checkbox"/> 错误代码: $("input").attr(&quo ...
- jquery实现复选框全选,全不选,反选中的问题
今天试了一下用jquery选择复选框,本来以为很简单的东西却有bug,于是搜索了一下找到了解决方法. html代码如下(这里没有用任何样式,就没有再放css了): <html> <h ...
- jquery操作复选框(checkbox)十二技巧
jquery操作复选框(checkbox)的12个小技巧. 1.获取单个checkbox选中项(三种写法)$("input:checkbox:checked").val()或者$( ...
随机推荐
- asp.net 错误跳转
每当用户访问错误页面时,会出现不友好的404错误,所以为了防止这种不友好,我们在web.config中的<system.web>节点下配置 <customErrors>,在出现 ...
- HTTP 错误 500.22 - Internal Server Error 检测到在集成的托管管道模式下不适用的 ASP.NET 设置
答案:在将WebDataHelper升级到VS2013是出现的这个错误,这个程序使用了URL重写的技术, 解决方法是:需要将重写的配置,迁移到system.webServer配置节中
- Threading.Tasks.Task多线程 静态全局变量(字典) --只为了记录
--------------------------------------------------------------后台代码---------------------------------- ...
- 创建单例的DbContext
/// <summary> /// 说明: /// 创建日期:2016/9/30 14:49:48 /// 创建人:曹永承 /// </summary> public clas ...
- Flexbox
使用 Flexbox 的牛逼布局 .container { display: -webkit-flex; display: flex; } .initial { -webkit-flex: initi ...
- 《算法竞赛入门经典》5.12TeX括号
/* *在TeX中,左双引号是``,右双引号是''.输入一篇包含双引号的文章,你的任务是把它转换成TeX的格式. *样例输入:"To be or not to be,"quoth ...
- [vijos P1112] 小胖的奇偶
第一次看到这题怎么也不会想到是并查集题目…星期五第一次看到这题,到今天做出来,实在是废了好多功夫.看了很多人的解题都有same和diff数组,我也写了,后来发现不对啊两个数组的话find函数怎么写呢? ...
- HTTPS Everywhere – 保障隐私和信息安全的利器
HTTPS Everywhere 是一款 Chrome 扩展程序,对于支持 HTTPS 的网站默认打开 HTTPS 加密传输来保障信息安全(HTTPS 介绍). HTTPS Everywhere 受到 ...
- Centos6升级内核2.6到3.x过程
最近公司有一个应用,安装需要内核版本3.1以后,不得已,需要升级下内核版本: 1. 安装必要依赖 # yum groupinstall "Development Tools" #y ...
- 嵌套遍历<s:iterator>map=new TreeMap(string,Map(string,User))
//嵌套遍历,先给外层的map(假设是放在root中的,如果放在context的map中,要加#)取个别名,放到Actioncontext中 <s:iterator value="ma ...