2015-09-24 256 views

回答

0

有文本字段代碼丟失,因此基於Trying to get the text field please specify to show and hide

HTML文本字段

<label class="option" for="edit-submitted-distributions-fieldset-1-fund-distribution-select-1">other (please specify)</label> 
<input id="edit-submitted-distributions-fieldset-1-widg-donation1otherdescription" type="text"> 

和JS代碼將

$(document).ready(function() { 
    $("#edit-submitted-distributions-fieldset-1-widg-donation1otherdescription").hide(); 
    $("#edit-submitted-distributions-fieldset-1-fund-distribution-select-1").click(function() { 
     if ($(this).val() === "0000~0000") { 
      $("#edit-submitted-distributions-fieldset-1-widg-donation1otherdescription").show(); 
     } else { 
      $("#edit-submitted-distributions-fieldset-1-widg-donation1otherdescription").hide(); 

     } 
    }); 
}); 

Fiddle

在JS代碼,你要綁定的label id="edit-submitted-distributions-fieldset-1-fund-distribution-select"

但是隱藏和顯示文本字段,如果點擊喜歡你單選按鈕,在問題的標題說,你要綁定單選按鈕ID點擊功能id="edit-submitted-distributions-fieldset-1-fund-distribution-select-1"

而這個$("#edit-submitted-distributions-fieldset-1-widg-donation1otherdescription").prop("disabled", false);只會使輸入不被禁用,它與隱藏/顯示輸入無關。