У меня есть страница для часто задаваемых вопросов. Теперь я хотел найти функциональность поиска на этой странице. Я успешно реализовал функцию поиска, но не могу открыть конкретный вопрос, связанный с текстом поиска. Любая помощь будет принята с благодарностью !!!
Ниже мой сценарий:
$(document).ready(function() {
$("#searchfaq").on("keypress click input paste", function() {
var val = $(this).val();
if (val.length) {
$("#faq_new .card .accordion").hide().filter(function() {
return $('.bloc_question .card-title', this).text().toLowerCase().indexOf(val.toLowerCase()) > -1 || $('.bloc_question .card-body', this).text().toLowerCase().indexOf(val.toLowerCase()) > -1;
}).show();
} else {
$(this).next().slideToggle(600);
$(".accordion-content").not($(this).next()).slideUp(600);
$(".accordion-toggle").not($(this)).css('color', '#000000');
$('.accordion-arrow').not($(this).find('.accordion-arrow')).rotate(0);
}
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input id="searchfaq" type="text" class="form-control" placeholder="Search FAQ">
<div class="bloc_question accordion-content" style="margin-bottom: 40px;">
<h3 id="A8" class="card-title" style="display: none;">Lorem Ipsum is simply dummy text</h3>
<a href="#top" class="btn_top" style="display: none;">top</a>
<br style="clear:both"> Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a
type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more
recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</div>