How make select2 placeholder for search input

后端 未结 4 1007
渐次进展
渐次进展 2021-01-17 14:50

How to make placeholder for select2 jQuery plugin. On StackOverflow many answers how to make placeholder there, but they about element\'s placeholder. I need to specify a pl

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-17 15:22

    Use event select2:open.

    $('#mySelect').select2().on('select2:open', function(e){
        $('.select2-search__field').attr('placeholder', 'your placeholder');
    })
    

提交回复
热议问题