How to hide optgroup/option elements?

前端 未结 1 913
[愿得一人]
[愿得一人] 2020-12-01 17:52

Is there a way to hide option or optgroup HTML elements? I\'ve tried calling hide() in jQuery, and also using regular Javascript to se

相关标签:
1条回答
  • 2020-12-01 18:41

    I figured that this solution works fine for me:

    Make another select e.g.

    $("#footer_canvas").after('<select id="parkingLot"></select>');
    

    then hide it

    $("#parkingLot").hide();
    

    When you want to 'hide' some optgroup, just 'park' it in this hidden select.

    $('#VehicleVehicleCategoryId optgroup[label="kategorie L"]').appendTo("#parkingLot");
    

    Same way you can make it visible. This is just the snippets of my solution, that works fine for me.

    0 讨论(0)
提交回复
热议问题