表单中的 jQuery 动画
let me start with my form:
I want to display only one line from the three below selectable options, based on selected stuff. How to do that?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是小提琴的修改版本,应该可以满足您的要求: http://jsfiddle.net/JZNMy/
关键点是,我使用选项上的值加上“-message”作为消息行的 ID,引用显示所选选项消息的行。然后,我绑定到选择框的
.change
事件,该事件获取当前选定的值,隐藏所有消息,然后显示相关消息。编辑:我更新了小提琴链接,该链接会自动触发选择框上的
change
事件,以确保显示其中一条消息。Here's a modified version of your fiddle that should do what you want: http://jsfiddle.net/JZNMy/
The key points are that I reference the row showing the message to the selected option using the value on the option plus '-message' as the id of the message row. Then, I bound to the
.change
event of the select box, which gets the currently selected value, hides all of the messages, then shows the related one.EDIT: I updated the fiddle link with one that automatically triggers the
change
event on the select box to make sure one of the messages is displayed.