解决方案 »

  1.   

    对于第一个问题:
        定义一个变量,来判断选中的是哪一个,再次选中时,变量将和选中一样,这是在取消选中即可
    对于第二个问题:
        给每一个input,加一个div,同控制div隐藏,来控制inpu的显示
      

  2.   


    <script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
            <script type="text/javascript">
    $(document).ready(function() {
    $(":radio").click(function() {
    //alert($(this).val());
    //alert($(this).attr("checked"));
    var flag = $(this).attr("checked") == "checked" ? false : "checked";
    if(flag == "checked") {
    $(this).next().attr("type","text");
    } else {
    $(this).next().attr("type","hidden");
    }
    $(this).attr("checked", flag);

    })
    })
            </script>
        </head>
        
        <body>
            <input name="1" type="radio" value="1" />第一个<input type="hidden" />
            <input name="2" type="radio" value="2" />第二个<input type="hidden" />
            <input name="3" type="radio" value="3" />第三个<input type="hidden" />
            <input name="4" type="radio" value="4" />第四个<input type="hidden" />
            <input name="5" type="radio" value="5" />第五个<input type="hidden" />
        </body>
      

  3.   


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
            <title>无标题文档</title>
            <script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
            <script type="text/javascript">
    $(document).ready(function() {
    $(":radio").click(function() {
    //alert($(this).val());
    //alert($(this).attr("checked"));
    var flag = $(this).attr("checked") == "checked" ? false : "checked";
    if(flag == "checked") {
    $(this).next().attr("type","text");
    } else {
    $(this).next().attr("type","hidden");
    }
    $(this).attr("checked", flag);

    })
    })
            </script>
        </head>
        
        <body>
            <input name="1" type="radio" value="1" />第一个<input type="hidden" />
            <input name="2" type="radio" value="2" />第二个<input type="hidden" />
            <input name="3" type="radio" value="3" />第三个<input type="hidden" />
            <input name="4" type="radio" value="4" />第四个<input type="hidden" />
            <input name="5" type="radio" value="5" />第五个<input type="hidden" />
        </body>
    </html>代码贴全了 楼主可以参考下
      

  4.   


    IE10上面没有效果
    IE中radio的选中 貌似是用true 来表示的  改成下面的试试var flag = $(this).attr("checked") ? false : true;
    if(flag) {
                            $(this).next().attr("type","text");
                        } else {
                            $(this).next().attr("type","hidden");
                        }
      

  5.   

    <input name="1" type="radio" />第一个<input type="text" style="display: none">
    <input name="2" type="radio" />第二个<input type="text" style="display: none">
    <input name="3" type="radio" />第三个<input type="text" style="display: none">
    <input name="4" type="radio" />第四个<input type="text" style="display: none">
    <input name="5" type="radio" />第五个<input type="text" style="display: none">
    <script type="text/javascript">
        window.onload = function(){
            var inputs = document.getElementsByTagName("input");
            for(var i= inputs.length;--i>=0;){
                inputs[i].index = 0;
                inputs[i].onclick = function(){
                    getNextSibling(this).style.display = (this.checked = !(this.index++%2)) ? "inline" : "none";
                }
            }
        };
        function getNextSibling(obj){
            var next=obj.nextSibling;
            while(next.nodeType!=1){
                next = next.nextSibling;
            }
            return next;
        }
    </script>IE禁止修改type所以考虑使用display隐藏或显示