How to open select programmatically
Try this for Hover:
JS:
$(document).ready(function(){$("#selectId").hover(function(){ $(this)[0].size=$(this).find("option").length;});$("#selectId").click(function(){ $(this)[0].size=0;});});
HTML:
<select id="selectId"> <option>Volvo</option> <option >Saab</option> <option>Mercedes</option> <option>Audi</option></select>
You can achieve this by setting the size of the select and having it float using position:absolute.
<div style="position:relative">.<select style="position:absolute;top:-8px;left:-20px" onClick="onAssign(this)"> <option>a</option> <option>b</option> <option>c</option></select></div>function openMySelect(){ document.querySelector(‘#mySelect’),size=YOUR_OPTIONS.length;}function onAssign(data,select){ select.size=1 // your logic}
I think I found a solution, at least works for me:
First, try to get the arrow of the ng-select
and then force a mousedown
event
let arrowSpan = document.querySelector('.ng-arrow-wrapper');arrowSpan.dispatchEvent(new CustomEvent('mousedown', { bubbles: true }))