日期:2014-05-16 浏览次数:20424 次
<html> <head> <title></title> <script src="jquery-1.7.2.min.js" type="text/javascript"></script> <style type="text/css"> #radio1,#radio2,#radio3{width:50px; background-repeat:no-repeat;} #radio1{ background-image:url("1.png");} #radio1.a{ background-image:url("11.png");} #radio2{ background-image:url("2.png");} #radio2.a{ background-image:url("22.png");} #radio3{ background-image:url("3.png");} #radio3.a{ background-image:url("33.png");}} </style> <script type="text/javascript"> $(function(){ $("input[name=p];radio").click(function() { $("input[name=p];radio").removeClass("a"); $(this).addClass("a"); }); }); </script> </head> <body> <input type="radio" name="p" id="radio1" /> <input type="radio" name="p" id="radio2" /> <input type="radio" name="p" id="radio3" /> </body> </html>
Ext.getCmp('myradio').setVisible(false);
------解决方案--------------------
<!DOCTYPE html> <html> <head> <title></title> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.js" type="text/javascript"></script> <style type="text/css"> #radio1,#radio2,#radio3{width:50px;height:20px;float:left;} #radio1{ background-color:#f5aece; } #radio1.a{ background-color:red;} #radio2{background-color:#aef5be;} #radio2.a{ background-color:green;} #radio3{ background-color:#aec6f5;} #radio3.a{ background-color:blue;} </style> <script type="text/javascript"> $(function () { //清空所有已选radio, 避免无法对应; 并隐藏 $("#pVirtulRadios :radio").removeAttr("checked").hide(); $("#pVirtulRadios label").click(function () { $("#pVirtulRadios label").removeClass("a"); $(this).addClass("a"); }); }); function test() { var $chkRadio = $("#pVirtulRadios :radio:checked"); if ($chkRadio.length == 0) { alert("没有选中任何值."); } else { alert("您选中了: "+$chkRadio.val() ); } } </script> </head> <body> <p id="pVirtulRadios" style="width:100%;" > <label id="radio1" for="radio4" ></label> <label id="radio2" for="radio5" ></label> <label id="radio3" for="radio6" ></label> <input type="radio" name="p" id="radio4" value="第1个" /> <input type="radio" name="p" id="radio5" value="第2个" /> <input type="radio" name="p" id="radio6" value="第3个" /> </p> <br /> <div style="width:100%;float:left;" > <input type="button" onclick="te