用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()或者$( ...
随机推荐
- SQL逻辑读变成零
使用缓存HINT 让逻辑读变成0. create table t as select * from dba_objects; insert into t select * from t; commit ...
- Hive的Transform功能
Hive的TRANSFORM关键字提供了在SQL中调用自写脚本的功能,适合实现Hive中没有的功能又不想写UDF的情况.例如,按日期统计每天出现的uid数,通常用如下的SQL SELECT date, ...
- CentOS hadoop启动错误 JAVA_HOME is not set and could not be found
... Starting namenodes on [] localhost: Error: JAVA_HOME is not set and could not be found. localhos ...
- --投资情况统计详情sql
--投资情况统计详情sqlselect BidRecord.*, RegInfo.UserName,UserInfo.phone,BorrowInfo.Title,BorrowInfo.BorrowC ...
- bzoj 2143: 飞飞侠
#include<cstdio> #include<iostream> #include<queue> #define inf 1000000000 #define ...
- ubnutu安装sougou 输入法
先安百度经验安装fcitx 1.首先下载sogoupinyin_2.0.0.0068_amd64.deb,点击安装后,会通过ubuntu软件中心安装,安装玩成后,任然是无法使用.然后: 2.然后执行下 ...
- EL表达式中获取list长度
在jsp页面中不能通过${list.size}取列表长度,而是 <%@ taglib uri="http://java.sun.com/jsp/jstl/core" pref ...
- Excel公式中双引号和单引号输入和显示以及函数的选择确认
[Excel中显示双引号] 1.直接输入双引号“”或单引号“ 2.工式中显示双引号需输入“”“”“”(六个引号)或单引号需输入“”“”(四个引号) [Excel中快速确认已选择的函数] 1.用键盘的上 ...
- LightOJ 1141 Program E
Description In this problem, you are given an integer number s. You can transform any integer number ...
- 学好C++必须要注意的十八个问题
转自 http://blog.chinaunix.net/uid-7396260-id-2056691.html 一.#include "filename.h"和#i nclud ...