I have three radio buttons with same name and different values.When I click the third radio button the checkbox and textbox going to be disabled.but when I choose other two radio buttons it must be show.I need the help in Jquery.Thanks in advance....

<form name="checkuserradio">
    <input type="radio" value="1" name="userradiobtn" id="userradiobtn"/> 
    <input type="radio" value="2" name="userradiobtn" id="userradiobtn"/>
    <input type="radio" value="3" name="userradiobtn" id="userradiobtn"/>
    <input type="checkbox" value="4" name="chkbox" />
    <input type="text" name="usertxtbox" id="usertxtbox" />
</form>

推荐答案

HTML

<span id="radiobutt">
  <input type="radio" name="rad1" value="1" />
  <input type="radio" name="rad1" value="2" />
  <input type="radio" name="rad1" value="3" />
</span>
<div>
  <input type="text" id="textbox1" />
  <input type="checkbox" id="checkbox1" />
</div>

Javascript

  $("#radiobutt input[type=radio]").each(function(i){
    $(this).click(function () {
        if(i==2) { //3rd radiobutton
            $("#textbox1").attr("disabled", "disabled"); 
            $("#checkbox1").attr("disabled", "disabled"); 
        }
        else {
            $("#textbox1").removeAttr("disabled"); 
            $("#checkbox1").removeAttr("disabled"); 
        }
      });

  });

Jquery相关问答推荐

使用带有 bootstrap 验证的 Ajax 函数时出现问题

确定元素是否是其父元素的最后一个子元素

表单提交之前的jQuery函数

如何在 jQuery 中 Select 特定的表单元素?

如何使用 jQuery 获取所有 ID?

提交前添加 POST 参数

jQuery 滚动到 Div

JavaScript / jQuery:测试窗口是否有焦点

如何知道字体(@font-face)是否已经加载?

jQuery中追加的相反

如何使用 Javascript/jQuery 确定图像是否已加载?

jQuery ajax (jsonp) 忽略超时并且不触发错误事件

如何使用 javascript (jquery) 将整数值添加到返回字符串的值中?

如何在 TypeScript 中获得 jQuery 自动完成功能?

判断 JS 对象中是否存在键

如何通过jQuery函数仅获取直接子元素

检测 jQuery UI 对话框是否打开

你会如何比较 jQuery 对象?

请求的资源错误中不存在Access-Control-Allow-Origin标头

bootstrap 日期和时间 Select 器