尝试显示和隐藏文本字段please specify
。这是我的代码。
`
答案 0 :(得分:0)
代码中缺少文字字段,因此基于Trying to get the text field please specify to show and hide
HTML text-field
<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();
}
});
});
在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);
仅使输入无法禁用,它与隐藏/显示输入无关。