Multiple select in Safari iOS 7

前端 未结 5 664
不知归路
不知归路 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 03:44

    I seem to have come up with a fix with mysteriously works with jQuery. I imagine you could vanilla-ify the code if you don't want the jQuery dependency:

    /**
     * iOS mutliple select fix.
     */
    if (navigator.userAgent.match(/(iPod|iPhone|iPad)/)) {
        $('select[multiple]').each(function() {
            $(this).prepend('');
            $(this).append('');
        });
    }
    

提交回复
热议问题