Change event doesn't work with select
When I choose another option nothing happens
My select
<select class="form-control select2 select_location" name="group_id">
@foreach($categories as $category)
<option value="{{ $category->id }}" @if($category->id == request()->get('group_id')) selected @endif>{{ $category->name }}</option>
@endforeach
</select>
My jquery
$('.select_location').on('change', function () {
console.log('hello')
})
i tried
$(".select_location").change(function () {
console.log('hello')
})
but not working
Is jquery loaded?
Try to assign an id to the
Example
<select class="form-control select2 select_location" name="group_id" id="test">
</select>
$("#test").change(function () {
console.log('hello')
})
I try to use change at the input, it works
but select doesn't
The new problem here is select2
I have also tried and it doesn't work
can you help me with teamview
Let me know if it's still not working.
Uncaught TypeError: $(...).select2 is not a function
Make sure your script loading is in correct order like below:
- jQuery, //if you are using laravel, it probably is app.js
- select2,
- your custom js files
thank you so much
its working
No problem. Please select the best answer to close the thread.
Please or to participate in this conversation.