Answer the question
In order to leave comments, you need to log in
How to create an optgroup with a label on the select?
Hello.
On the form I create a form element of type select
var select = document.createElement("select");
select.name="main_select_region";
//select.className="selectpicker show-tick form-control";
select.setAttribute('class', 'selectpicker');
select.setAttribute('data-live-search', 'true');
select.setAttribute('data-size', '15');
for (var i = 0; i < jsondata.regions.length; i++) {
select.options[i]=new Option(jsondata.regions[i].name, jsondata.regions[i].name);
...
<optgroup label="Группа1">
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question