Search code examples
javascripthtmlselectoptgroup

How to select optgroup


Is there a way to select optgroup?

It seems to be disabled all the time. I have tried searching for javascript solutions but could not find any good ones.


Solution

  • Well you can have an example here: http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_optgroup

    Its just more like a tag, to tell about the options below. Or just like a caption.

    If you want to select multiple ones then you might use jQuery created select. I mean a custom one, or you can use checkboxes and merge them in a list as a select tag.

    There is no other way to select two options from one select element. Each select must have one and only one value.

    Other way is to add the value to each option, and then seperate them using ,. But there is no option to select optgroup Its just a way to group the options under it or more like a label to them.

    I am getting a warning alert that I am missing a point, do you want to click on the optgroup and select a value under it? I think this might be the condition!