Contact Form 7 Optgroup

c633a1683d7a35a5dde36807497449a690dd6ab0

HTML như sau : 

<select id="some_select">
<option>optgroup-First Group</option>
<option>Some Option</option>
<option>Some Option</option>
<option>Some Option</option>
<option>Some Option</option>
<option>Some Option</option>
<option>endoptgroup</option>
<option>optgroup-Second Group</option>
<option>Some Option</option>
<option>Some Option</option>
<option>Some Option</option>
<option>Some Option</option>
<option>Some Option</option>
<option>endoptgroup</option>
</select>

JS như sau :

$(function(){
var foundin = $('#some_select option:contains("optgroup-")');
$.each(foundin, function(value){
var updated = $(this).val().replace('optgroup-','');
$(this).nextUntil('option:contains("endoptgroup")').wrapAll('<optgroup label="'+updated+'"></optgroup>');
});
$('#some_select option:contains("optgroup-")').remove();
$('#some_select option:contains("endoptgroup")').remove();
});

0938.54.84.99