<div id="d3" 
    style="background-color: #663300; height: 63px; color: #CCFFCC;">
        D3<asp:TextBox ID="TextBox3" runat="server" Width="90px"></asp:TextBox>
        <asp:RadioButtonList ID="RadioButtonList2" runat="server" 
            RepeatDirection="Horizontal" RepeatLayout="Flow">
            <asp:ListItem>1</asp:ListItem>
            <asp:ListItem>2</asp:ListItem>
            <asp:ListItem>3</asp:ListItem>
        </asp:RadioButtonList>
        (输入才能选择!)</div>页面有一个textbox和一个RadioButtonList,我想用JQuery设置默认RadioButtonList不可选,当用户输入时,RadioButtonList才可用,一旦清空立即变为不可用,呈灰色而非隐藏。
我只学会隐藏,但是这样不好。设置不可用又不知怎么做,请教下大家,谢谢! 

解决方案 »

  1.   

    加一个单属性disabled,或者是加disabled=true
      

  2.   

    $(":radion").attr("disabled", "disabled");
      

  3.   

    谢谢大家的回答,我想要的是:当用户输入时,RadioButtonList才可用,一旦清空立即变为不可用,呈灰色而非隐藏。
    大家的回答是单选框不可用,但是后面的功能呢?求解ing
      

  4.   

    $(document).ready(function(){
      $('#TextBox3').keyup(function(){
        $(':radio').attr('disabled',this.value==''?true:false);
      });
    })
      

  5.   


    先给RadioButtonList2加上disabled=“disabled”的属性。
    然后给TextBox3的onblur事件加个方法<asp:TextBox ID="TextBox3" runat="server" Width="90px" onblur="chdisabled()"></asp:TextBox>再写个chdisabled的方法:
    function chdisabled()
    {
    if($("#TextBox3").val()!="")
    {
    $("#RadioButtonList2").removeAttr("disabled");
    }
    }
      

  6.   

    获取RadioButtonList1的HTML源码,你会发现这个ID下会有几个子节点,也就是那些单选按钮的解析码,名字是RadioButtonList_0、RadioButtonList_1 等等。获取这些子节点,然后赋给disabled值为true。
    想知道输入框有没有输入就用blur监听,写法如click,接下去就是逻辑判断了。值不为空则移除disabled。
    思路就是这样,加油!