Skip to content

Commit

Permalink
updated search button functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
shivansh090 committed Dec 20, 2023
1 parent edf69dc commit 85ac937
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@
</ul>
</div>
<div class="search-bar flex">
<form >
<input id="search-text" type="text" class="news-input" placeholder="e.g. Science">
<button id="search-button" class="search-button">Search</button>
<button id="search-button" class="search-button">Search</button></form>
</div>
</div>
</nav>
Expand Down
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ function onNavItemClick(id) {
const searchButton = document.getElementById("search-button");
const searchText = document.getElementById("search-text");

searchButton.addEventListener("click", () => {
searchButton.addEventListener("click", (event) => {
event.preventDefault();
const query = searchText.value;
if (!query) return;
loadSampleData(query);
Expand Down
2 changes: 1 addition & 1 deletion style.css
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ nav {

.news-input {
width: 200px;
height: 100%;
height: 32px;
padding-inline: 12px;
border-radius: 4px;
border: 2px solid #bbd0e2;
Expand Down

0 comments on commit 85ac937

Please sign in to comment.