Multiple select in Safari iOS 7

前端 未结 5 679
不知归路
不知归路 2020-12-03 03:08

When I use the multiple option in a select dropdown - safari runs into weird issues. When I select an option and say Done, the dropdown goes back to showing \'0 items\'. But

5条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-03 04:02

        // hack for iPhone 7.0.3 multiselects bug
        if(navigator.userAgent.match(/iPhone/i)) {
            $('select[multiple]').each(function(){
                var select = $(this).on({
                    "focusout": function(){
                        var values = select.val() || [];
                        setTimeout(function(){
                            select.val(values.length ? values : ['']).change();
                        }, 1000);
                    }
                });
                var firstOption = '';
                select.prepend(firstOption);
            });
        }
    

提交回复
热议问题