2017-06-27 26 views
0

單擊(數量)單選按鈕時,必須啓用數字類型框。單擊(速率)單選按鈕時禁用。單選按鈕啓用號碼類型

我看來

<input type="radio" class="radioBtn" name="quantity" value="yes" id="rad1" onclick="radio()"/>PRN 
    <input type="radio" class="radioBtn" name="quantity" value="no" id="rad2" onclick="radio()" />Qty 
    <input type="number" name="someid" id="textfield" disabled/> 

我的javascript

$(".radioBtn").click(function radio() { 
      $("#textfield").attr("disabled", true); 
      if ($("input[name=quantity]:checked").val() == "yes") { 
       $("#textfield").removeattr("disabled"); 
      } 

    }); 

我的鏈接可以查看和js

+0

除了幾個錯誤,使用內聯和jQuery事件處理程序等,這裏的問題到底是什麼? – adeneo

+0

我的連接視圖和js的鏈接 ashwanth

+0

單擊單選按鈕時,我無法禁用文本框 – ashwanth

回答

0

我不知道這是否會在您的工作結束但在這裏看起來不錯。只需將removeattr更改爲removeAttr

$("#textfield").removeAttr("disabled"); 

另請確保您的網站中包含JQuery。 爲了更好地瞭解爲什麼某些東西可能不起作用,請按F12在瀏覽器中打開控制檯。這會顯示任何錯誤。