jquery实现有两个复选框,要么可以选中一个,要么两个全不选。 jquery复选框打勾全选 一个不勾中 则不全选 全勾中则又...
\u5982\u4f55\u7528JQuery\u64cd\u4f5c\u4e00\u4e2a\u590d\u9009\u6846\uff0c\u6765\u5b9e\u73b0\u5176\u5b83\u590d\u9009\u6846\u7684\u5168\u9009/\u5168\u4e0d\u9009\u64cd\u4f5c$("input[name='chkSelectAll']").click(function () {
if ($(this).attr("checked")) {
$("input[name='chkSelectAll']").attr("checked", "checked");
$("input[name='chkSelect']").attr("checked", "checked");
}
else {
$("input[name='chkSelectAll']").attr("checked", null);
$("input[name='chkSelect']").attr("checked", null);
}
});
\u4f60\u7684\u8bdd\u597d\u7ed5\uff0c
\u6bd4\u5982\u4f60\u7684\u5168\u9009\u590d\u9009\u6846\u7684id\u662fchkAll\uff0c\u5176\u5b83\u7684\u5355\u9009\u6846\u5305\u542b\u5728id\u4e3amyDiv\u7684div\u91cc\u9762\u90a3\u4e48\u4ee5\u4e0b\u4ee3\u7801\u6765\u5b9e\u73b0
$('#chkAll').click(function(){ if($(this).attr('checked')){ //\u9009\u4e2d\u4e86\u5168\u9009\uff0c\u4e0b\u9762\u7684\u5168\u52fe\u4e2d $('#myDiv').find('checkbox').attr('checked',true); }else{ $('#myDiv').find('checkbox').attr('checked',false); }});$('#myDiv').find('checkbox').change(function(){ if($('#myDiv').find('checkbox').not("input:checked").size() <= 0){ //\u5982\u679c\u5176\u5b83\u7684\u590d\u9009\u6846\u5168\u90e8\u88ab\u52fe\u9009\u4e86\uff0c\u90a3\u4e48\u5168\u9009\u52fe\u4e2d $('#chkAll').attr('checked',true); }else{ $('#chkAll').attr('checked',false); }});
<html>
<head>
<title></title>
<script src="jquery-1.6.4.min.js"></script>
<script>
$(function(){
$(':text').attr('disabled','disabled');
$(':checkbox').click(function(){
var chk = $(':checkbox:checked');
if(chk.length == 1){
if(chk.attr('id')=='chk1') {$('#txt1').removeAttr('disabled');$('#txt2').attr('disabled','disabled');$('#txt1').focus();}
else {$('#txt2').removeAttr('disabled');$('#txt1').attr('disabled','disabled');$('#txt2').focus();}
}
else $(':text').attr('disabled','disabled');
})
})
</script>
</head>
<body>
<input type="checkbox" id="chk1"><input type="text" id="txt1">
<input type="checkbox" id="chk2"><input type="text" id="txt2">
</body>
</html>
判断value属性就可以了
既然有推荐答案,就不写了……
路过……
绛旓細<!DOCTYPE html> .hide{ display: none;} (function(){ ('.cbx').click(function(){ c = $(this).is(":checked");t = $(this).attr("target");if(!c)('#o'+t).hide();else ('#o'+t).show();});}) ...
绛旓細浣犲彲浠ュ皾璇曠敤鐢jQuery锛浠g爜寰堢畝鍗曪細(":checkbox").attr("checked","checked");//鍏ㄩ 鍙夋嫨涓涓殑璇濋渶瑕佺粦瀹氫簨浠 (":checkbox").bind("click",function(){ (":checkbox").removeAttr("checked");//鍙栨秷鍏ㄩ (this).attr("checked","checked");//閫夋嫨涓涓 });
绛旓細2.璁剧疆checkbox琚変腑鐢╝ttr();鏂规硶锛("input[name='box']").attr("checked","checked");鍦℉TML涓紝濡傛灉涓涓閫夋琚変腑锛屽搴旂殑鏍囪涓 checked="checked"銆 浣嗗鏋滅敤jquery alert($("#id").attr("checked")) 鍒欎細鎻愮ず鎮ㄦ槸"true"鑰屼笉鏄"checked"锛屾墍浠ュ垽鏂 if("checked"==$("#id")....
绛旓細var showChoose = $("input[NAME='Product interest']:checkbox:checked").map(function(){ return $(this).val();}).get().join();alert(showChoose);//鍏抽敭瀛梞ap();
绛旓細鐢jquery if($("#id :checkbox:checked").length>2){ alert('璇烽夋嫨灏戜簬涓や釜')}
绛旓細寮曞叆jquery 棣栧厛寮曞叆jquery鏀寔锛岀瑪鑰呭湪jquery鐨鍩虹涓瀹炵幇璇ュ姛鑳斤紝娌℃湁浣跨敤js 澶嶉夋椤甸潰鎻忚堪 1銆佸畾涔1涓閫夋鐢ㄤ簬鍏ㄩ夛紝灞炴ame涓篴llSel 2銆佸畾涔5涓閫夋鐢ㄤ簬鍒嗛夛紝灞炴ame涓簊elect 鍔熻兘鎻忚堪锛 1銆佸嬀閫夊叏閫夋寜閽椂锛屼笅闈1-5澶嶉夋鍏ㄩ儴閫変腑锛 2銆佸彇娑堝嬀閫夊叏閫夋寜閽椂锛屼笅闈1-5澶嶉夋鍏ㄩ儴鍙栨秷閫変腑...
绛旓細鎮ㄥソ锛氫綘鍙互鐢jquery ui 涓殑鏍戝舰鎻掍欢锛屽甫澶嶉夋鐨勶紝涓嶅甫澶嶉夋鐨勭瓑绛夋晥鏋滈兘鏈夛紝寰堝己澶с傜粦瀹氭暟鎹篃寰堟柟渚匡紝鍙互鐩存帴鎶婃暟鎹簱涓殑鏁版嵁璇诲嚭鏉ヨ浆鍖栦竴涓嬪氨鍙互缁戝畾鍒皌ree涓婁簡銆
绛旓細涓婂浘闀囨ゼ锛氫笂浼犱笉浜嗗浘鐗囷紝瀹屾暣绛旀璇风湅杩欓噷 棣栧厛锛屼笉鐭ラ亾浣犺鐨勫摢涓挩璇㈤〉闈傛潵璇翠笅鎴戠殑鎬濊矾锛堟牴鎹緥瀛愶級锛1銆佹湁涓涓閫夋缁勶紝姣忎釜澶嶉夋缁勬湁涓変釜绛旀锛岀瓟妗堢殑鍒嗘暟鍒嗗埆涓 1锛2锛3銆2銆佹牴鎹渶鍚庣殑寰楀垎鏉ュ喅瀹氬浣曟洿鏀归摼鎺ャ傚皬浜10锛屽垯璺宠浆鍒伴摼鎺1锛涘ぇ浜10灏忎簬20锛屽垯璺宠浆鍒伴摼鎺2銆備笂渚嬪瓙锛 澶嶉...
绛旓細{ getTotal();} });});});function getTotal() { var total = 0;(":checkbox[name=fs]").each(function() { var v = $(this).val();total += parseInt(v);});alert(total);} 杩愯娴嬭瘯閫氳繃浜 鍥犱负浣犺鐨勬槸閫変腑2涓閫夋涔嬪悗鍐嶅脊鍑轰袱涓肩殑鍜岋紝鎵浠ユ垜涔熷氨鎸夌収浣犵殑鎰忔濇潵浜 ...
绛旓細浣犺瘯涓嬫寜浣弒hift+榧犳爣鐐瑰嚮锛屽氨璺焪indows閫夋嫨鏂囦欢閭f牱