code:
//html //The first option must be empty in order to get placeholder working! <select id="belongingUserId" placeholder="请选择归属人"> <option></option> <option>Option value</option> </select> //js $(function () { $("#belongingUserId").select2({ allowClear: true}); }); //未选择时,取值时为空,取值时要判断 var belongingUserId = $('#belongingUserId').val(); if (belongingUserId == '') belongingUserId = '-1';//如果是空,赋默认值
效果:
https://hromnik.wordpress.com/2012/10/18/select2-placeholder-does-not-work-solution/