Skip to content

Instantly share code, notes, and snippets.

@herbie4
Created August 12, 2022 09:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save herbie4/62dfe791a2ad1fc0e57a19b9f7c6f6fe to your computer and use it in GitHub Desktop.
Save herbie4/62dfe791a2ad1fc0e57a19b9f7c6f6fe to your computer and use it in GitHub Desktop.
Avada FAQ keyword search list toggle
<div id="form">
<form action="#" class="search">
<input type="text" placeholder="typ een zoekwoord" class="filterinput" />
<small><a href="#" id="filter_reset">Maak zoekveld leeg</a></small>
</form>
</div>
<script>
jQuery("#filter_reset").click(function($){
jQuery("#form input").val('');
jQuery('.fusion-filter-all a').click();
});
(function ($) {
jQuery.expr[':'].Contains = function(a,i,m){
return (a.textContent || a.innerText || "").toUpperCase().indexOf(m[3].toUpperCase())>=0;
};
//live search function
function live_search(list) {
$(".filterinput")
.change( function () {
//getting search value
var searchtext = $(this).val();
if(searchtext) {
//finding If content matches with search keyword
$matches = $(list).find('.fusion-faq-post:Contains(' + searchtext + ')');
//hiding non matching lists
$('.fusion-faq-post', list).not($matches).slideUp();
//showing matching lists
$matches.slideDown();
//console.log($matches);
} else {
//if search keyword is empty then display all the lists
$(list).find(".fusion-faq-post").slideDown(200);
}
return false;
})
.keyup( function () {
$(this).change();
});
}
$(function () {
live_search($("#accordian-1"));
});
}(jQuery));
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment