如何通过 jQuery 关闭选择框中的不同项目?
使用 Wordpress(iDeasilo 的联系表单插件)并需要帮助来执行特定任务。我用谷歌搜索过,但找不到我要找的东西。刚开始使用 jQuery,因此任何帮助都会有所帮助。
我的问题是:
如果用户单击特定的单选按钮,我如何能够隐藏或不允许用户在选择框中选择其他选项?
因此,如果有三个不同的单选按钮(三明治、炸玉米饼和披萨),我就点击“披萨”。选择框选项应保持默认状态。当我单击选择框时,所有其他选项都会消失或被禁用,因此您无法从列表中进行选择。但这只会在您单击“披萨”时发生。
我将如何实现这个目标?
Working with Wordpress (contact-form plugin by iDeasilo ) and needed help performing a certain task. I've searched Google, but was unable to find what I was looking for. New to working with jQuery, so any help will help.
My question is:
How would I be able to hide or not allow a user from selecting other option in a select box, if he/she clicks on a specific radio button?
So if there is three different radio buttons (sandwich, taco and pizza), and I was to click on "pizza". The select box option should stay just at it's default. When I click the select box, all other options should disappear or be disabled so you can't choose from the list. But this should only happen when you click on "pizza".
How would I accomplish this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我会将一个事件处理程序附加到一个控件(单选按钮),这会影响/更改选择控件中的选项:
只需在进行下拉/选择时将“条件”类附加到条件选项即可。
I would attach an event handler to the one control (radio button), which affects/changes the options in the select control:
Just attach the 'Conditional' class to the conditional options when you make the drop down/select.