I need to implement for mobile devices, creating a select, and after its creation, it must already be expanded, however this does not work the way you need on iOS, it just does not expand the select, but on Android works correctly below a link to a sample that did, it demonstrates what I need, I thank anyone who can help me.
var button = document.getElementById("create");
button.addEventListener("click", createSelect);
j = 0;
function expanded(){
var element = document.getElementById("select"+j);
element.dispatchEvent(new MouseEvent("mousedown"));
setTimeout(function () {
element.dispatchEvent(new MouseEvent("click"));
}, 100);
setTimeout(function () {
element.dispatchEvent(new MouseEvent("mouseup"));
}, 200);
j +=1;
}
function createSelect(){
var i;
var select = document.createElement("select");
select.id ="select"+j;
document.getElementById("container").appendChild(select);
for(i=0; i<20; i++){
var option = document.createElement("option")
option.text = "Item " + i;
select.add(option);
}
setTimeout(expanded, 1);
}