When I change select box, I have displayed select box with some values from DB using ajax like below image,
But I want to display select box like below,
So I tried code to change option tag into optgroup tag using jquery,
function callback() {
if (req.readyState == 4) { //complete and response received from server
if (req.status == 200) { //the status==200 is getting you a message where the server says: 'Hey man I do the work!'
var message = req.responseText;
$("#selectboxDivId").html(message);
var oSrc = document.getElementById('SelectFeatures');
for (var i = 0; i < oSrc.options.length; i++) {
if (oSrc.options[i].text=="Game" | oSrc.options[i].text=="Lession" | oSrc.options[i].text=="Summary") {
// oSrc.options[i].disabled=true;
// $(this).css({ 'color' : 'red','font-size' : '250%'} );
// Here I want to chnage option to optgroup tag!!! how???
}
}
}
}
}
I hope someone will help me out!