How to open select programmatically

前端 未结 4 1479
醉梦人生
醉梦人生 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:16

    The answer provided by haste doesn't work:

    var cb = element[0].getElementsByClassName('some-selector')[0];
    var event = new MouseEvent('mousedown', {
        'view': window,
        'bubbles': true,
        'cancelable': true
    });                        
    cb.dispatchEvent(event);
    

    I use more simple method:

    var cb = element[0].getElementsByClassName('some-selector')[0];
    angular.element(cb).triggerHandler('click');
    

提交回复
热议问题