Created
August 12, 2022 09:28
-
-
Save herbie4/62dfe791a2ad1fc0e57a19b9f7c6f6fe to your computer and use it in GitHub Desktop.
Avada FAQ keyword search list toggle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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