简体   繁体   English

选择值后如何将下拉菜单转换为标签,然后单击按钮再次转换为下拉菜单

[英]How to convert the dropdown menu to label once the value is selected.and again convert into the dropdown onclick of the button

i have dialog on which different dropdowns are there if i select the value then it the selected value will be shown as label and there is a button in side as "Change" so if user click on change then again label will be converted into dropdown. 我有一个对话框,如果我选择该值,则在其上有不同的下拉菜单,则所选择的值将显示为标签,并且在侧面有一个“更改”按钮,因此,如果用户单击更改,则再次将标签转换为下拉菜单。 the same thing for the other dropdown 其他下拉菜单也一样

If it were me, I would do this as 2 separate controls. 如果是我,我将作为2个单独的控件执行此操作。 Have the drop-down available, with the label hidden. 在下拉菜单中隐藏标签。 Once they select the value, set the label text to the value, then show the label. 他们选择了值后,将标签文本设置为该值,然后显示标签。 Have the button hide the label again, showing the drop-down... 让按钮再次隐藏标签,显示下拉菜单...

Have a span near the dropdown. 在下拉列表附近有一个跨度。 when the option is selected, update the span with the selected value using jquery. 选择该选项后,使用jquery用所选值更新跨度。 Then hide the dropdown 然后隐藏下拉菜单

using this code you can get the selected value and update it in the span tag and it will display as label and then you can hide the dropdown box 使用此代码,您可以获取所选值并在span标签中对其进行更新,它将显示为标签,然后可以隐藏下拉框

$("# dropdown id").change(function () {
    //update the value in to span
    $('# span id').html($('# dropdown id').val());
    $('# dropdown id').hide();
});

When you click the change button, you can show the hidden dropdown box and hide the span tag. 单击更改按钮时,可以显示隐藏的下拉框并隐藏span标签。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM