I have a problem with the function down below. The function does show/hide a div when clicking a link with the class "show-more". It also changes an icon, which works perfectly fine. Now the problem is that on the same page, there is a ajax filter (example here: https://facetwp.com/demo/cars/) and when I use this filter before, I can't click the link anymore, when clicking it it only reloads the page and not using the function anymore. Any ideas? Thanks in advance!
SOLUTION:
<script>
jQuery(document).ready(function($) {
$('body').on('click', 'a.show-more', function(e) {
e.preventDefault();
$('.show-more').toggleClass("active");
var $this = $(this).parents('.product');
$this.find('.productinfo').toggle(0, 'slide');
$(this).find('.bi').toggleClass('bi-arrow-up-short')
});
});
</script>
jQuery(document).ready(function($) {
$('.show-more').click(function(e) {
e.preventDefault();
$('.show-more').toggleClass("active");
var $this = $(this).parents('.product');
$this.find('.productinfo').toggle(0, 'slide');
$(this).find('.bi').toggleClass('bi-arrow-up-short')
});
});
<div class="product">
<div class="col-one">1</div>
<div class="col-two">2</div>
<div class="col-three">3</div>
<div class="col-four">4</div>
<div class="col-five"><a href="" class="show-more">See Details <i class="bi bi-arrow-down-short"></i></a></div>
<div class="col-six productinfo">This content is originally hidden</div>
</div>
.productinfo {
display: none;
}