How to open select programmatically

前端 未结 4 1477
醉梦人生
醉梦人生 2021-01-17 10:07

Does anyone know if it is possible to open a select programmatically in angularjs. Ive tried

angular.element(el).trigger(\'focus\');
angular.element(el).trig         


        
4条回答
  •  一整个雨季
    2021-01-17 10:19

    try this

    function openSelect(selectId) {
        var event = new MouseEvent('mousedown', {
            'view': window,
            'bubbles': true,
            'cancelable': true
        });
        var cb = document.getElementById(selectId);
        cb.size=4;
        cb.dispatchEvent(event);
    }
    openSelect("testId");

    or read more here Triggering built-in events

提交回复
热议问题