Javascript 如何在Laravel5中禁用选择?

Javascript 如何在Laravel5中禁用选择?,javascript,jquery,css,laravel,bootstrap-4,Javascript,Jquery,Css,Laravel,Bootstrap 4,大家早上好 我使用Laravel 5,并为选择类“selectpicker” 我希望我能做到这一点,当我点击其中一个选项,使这个禁用或无。因为我用下面选项的内容创建了一个div。因此,如果select选项不是disable或none,它将再次创建一个div 有两天我不能做这件事 <select id="interlocutorsList" name="interlocutorsList" class="selectpicker" data-width="100%" data-style="

大家早上好

我使用Laravel 5,并为
选择
类“selectpicker”

我希望我能做到这一点,当我点击其中一个选项,使这个禁用或无。因为我用下面选项的内容创建了一个div。因此,如果select选项不是disable或none,它将再次创建一个div

有两天我不能做这件事

<select id="interlocutorsList" name="interlocutorsList" class="selectpicker" data-width="100%" data-style="btn-info select2" data-live-search="true">
 <option id="titleSelectInterlocutor" class="" value=""  selected>Faites un choix</option>
  @foreach( $othersInterlocutors as $interlocutor)
   <option value="{{$interlocutor->id}}" id="option{{$interlocutor->id}}" class="" style="overflow: hidden; width:100%;" data-tokens="">{{$interlocutor->name.' '.$interlocutor->firstName}}
   </option>
  @endforeach
</select>

合唱团
@foreach($其他对话者作为$对话者)
{{$interlector->name.'.$interlector->firstName}
@endforeach
$(“#对话者列表”)。更改(函数(){
$('titleSelectInterlocator').addClass(“d-none”);
var interlocatorselect=$(“#interlocatorslist”).val();
$(“#选项”+对话者选择).addClass(“d-none”);
var nameSel=对话者stab[对话者选择];
$(“.interlocatorsel”).append(“

您可以在启用事件时在选项中添加disabled='disabled'

<option value="opel" disabled='disabled'>Opel</option>
如果您使用的是jQuery 1.6+:

jQuery('#option'+nbCustom).prop("disabled", true);
下面是一个例子。

沃尔沃汽车
萨博
欧宝
奥迪

您想禁用任何一个选项吗?当我单击该选项时,它会创建一个
div
,如果我再次打开
选择
,我希望单击的选项不再可用。
jQuery('#option'+nbCustom).attr("disabled", 'disabled');
jQuery('#option'+nbCustom).prop("disabled", true);