Trying to implement a JavaScript search feature to find a div
within the same page. The current code being used for the search query display is:
$('.form-search').on('submit',function(){return false;});
$('.form-search .btn').on('click', function(e){
var query = $.trim($(this).prevAll('.search-query').val()).toLowerCase();
$('div.staff-container .bold').each(function(){
var $this = $(this);
if($this.text().toLowerCase().indexOf(query) === -1)
$this.closest('div.staff-container').fadeOut();
else $this.closest('div.staff-container').fadeIn();
});
});
A demonstration with HTML and CSS can be found here:
The goal is to display the div
while the user is typing. The concept of using a refresh function is known, but struggling with understanding the JavaScript language. Learning as a beginner student.