检查单选按钮时立即隐藏文本字段
我想要的是,当用户选择第一个选项时,文本字段将消失,当用户选择第二个选项时,文本字段将立即再次出现。这是一些代码:
<input type="radio" name="RadioGroup0" value="1" id="student" />
<input type="radio" name="RadioGroup0" value="0" id="not student" />
并且想要隐藏/显示这个:
<label for="department">department:</label>
<input name="department" type="text" class="label" value="" />
我已经尝试过任何方法,所以我将不胜感激任何答案
What I want is when the user chooses the first option the textfield will disappear and when the users chooses the second the textfield will appear again instantly. Here's some code:
<input type="radio" name="RadioGroup0" value="1" id="student" />
<input type="radio" name="RadioGroup0" value="0" id="not student" />
and want to hide/show this:
<label for="department">department:</label>
<input name="department" type="text" class="label" value="" />
I have tried anything so I'll appreciate any answer
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 click、keyup 和 change 事件上,显示或隐藏适当的元素(jQuery 使这变得更容易)。处理所有事件的原因是只有在元素失去焦点后才可能触发值更改。
快乐编码。
On the click, keyup, and change events, show or hide the appropriate elements (jQuery makes this easier). The reason for handling all the events is that the value change may only be triggered after the element loses focus.
Happy coding.