I recently implemented the following Bootstrap 4 HTML structure for a search feature:
<div class="col-sm-3 col-md-3 search-header">
<form class="navbar-form" role="search">
<div class="input-group">
<input type="text" class="form-control search-box " placeholder="Search" name="srch-term" id="srch-term">
<div class="input-group-btn">
<button class="btn btn-default btn-search" onclick="ss()"><i class="glyphicon glyphicon-search"></i></button>
</div>
</div>
</form>
</div>
However, I'm facing an issue where clicking the search button causes the entire page to refresh. Despite adding an OnClick() event bound to a custom function (ss()) which only triggers an alert, the form still refreshes.
I am now looking to bind the search button to a JavaScript function that will handle the actual search functionality. How can I achieve this?