当Lavavel Dropdown菜单选择特殊项目时,如何执行JavaScript操作

Here is a part of Lavavel drop-down menu.

<div class="col-sm-6">
    <div class="form-group mb-20">
        <label><strong>{{trans('string.select_wallet')}}</strong></label>
        {!!Form::select('Wallet_id', $WalletList, null,
                         ['class'=>'form-control','required'=>'required'])!!}
    </div>
</div>

In this WalletList, 2 wallet A & B are able to be selected. I would like to have a JavaScript when B wallet is selected, how should I do?

Try these

First provide an Id to Select to identify Select or change Event:

{!!Form::select('Wallet_id', $WalletList, null,
        ['class'=>'form-control','required'=>'required', 'id' => 'Wallet_id'])!!}

After that use jQuery for fetching event and executing code:

$('#Wallet_id').change(function(){ 
    if($(this).val() == 'B'){
        /* Do Something */
    }
});

Add an id to the element

{!!Form::select('Wallet_id', $WalletList, null,['class'=>'form-
control','required'=>'required', 'id' => 'MySelect'])!!}

and use jQuery:

var element = document.getElementById("MySelect");
var selectedElement = element.options[e.selectedIndex].text;

and just search with JavaScript when the item changes:

if (selectedElement == (text of your B element))
{
  //do what you want to do.
}