I have created a local page search input box that currently filters results as you type. However, I am looking to modify it so that the search/filter function only executes when a specific button is pressed. Essentially, I want users to input their lookup data into the box and then trigger the search by clicking the button.
While there are numerous solutions available online for similar issues, many involve using PHP as a submit button, which is not the approach I'm seeking.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("#myInput").on("keyup", function() {
var value = $(this).val().toLowerCase();
$("#myDIV *").filter(function() {
$(this).toggle($(this).text().toLowerCase().indexOf(value) > -1)
});
});
});
</script>
<input id="myInput" type="text" placeholder="Search for word or phrase..">
<div id="myDIV"> <!-- div:called from search script -->
If anyone could provide assistance with this customization, I would greatly appreciate it.
Thank you in advance!