I have a function toggleVariantList which is responsible for displaying a dropdown. Is it possible to make the toggleVariantList method fire through the event listener without using onClick?
Dropdown code PHP Laravel:
<div class="variant-checker__button" onclick="toggleVariantList(this)">
<div class="default-item-wrap">
<span class="default-item">
{{ $Product->variants->where('stock_status', 1)->first()->attribute_values[0]->varchar ?? $Product->attribute('volume')->first()->valuesToHuman() }}
</span>
<svg class="ic icon-arrow-down">
<use xlink:href="#icon-arrow-down"></use>
</svg>
</div>
</div>
<div class="variant-checker-buttons-list">
@foreach($Product->variants as $variant)
@if($variant->image && $variant->stock_status === 1)
<button class="list-item button-item" onclick="changeVariant(this)" data-value="{{ $variant->id }}" product-name="{{ $variant->title }}" data-price="{{ $variant->price }}" data-image="http://onelove.ua/storage/{{ $variant->image->path }}">
{{ $variant->attribute_values[0]->varchar }}
</button>
@endif
@endforeach
</div>
@push('script')
<script>
function toggleVariantList(button) {
var $container = $(button).closest('.variant-checker');
$container.find('.variant-checker-buttons-list').toggleClass('active');
}
</script>
@endpush