我有一个checkbox
的列表,当用户单击others option
时,将打开text field
。这在方案1中正常工作,但在方案2中不起作用。 方案1:用户首先选择选项cat,然后选择其他选项,然后文本字段按预期方式显示。 [工精细,文本字段显示如预期] 方案2:如果用户首先选择其他选项(文本字段intially显示),但如果他的文本域隐藏后选择猫选项[文本字段中消失]Jquery:检查复选框中的选项显示文本框
请找到下面的代码:
$(".animals").change(function() {
//check if its checked. If checked move inside and check for others value
if (this.checked && this.value === "other") {
//add a text box next to it
$("#other-text").show();
} else {
//remove if unchecked
$("#other-text").hide();
}
});
这是我的小提琴: http://jsfiddle.net/Kritika/XSzKu/
如何使这些信息进行情景2也行? 在此先感谢。
是该做的之前。谢谢 :-) 。会接受你的答案 – Pbk1303