Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

178
Views
El botón de búsqueda no usará onclick

Tengo este archivo js codificado y cuando trato de llamar a mi botón de búsqueda, ¡no sucede nada cuando hago clic en el botón! No hay error ni nada, solo un botón en el que se puede hacer clic. ¿Alguna ayuda? index.hbs mi barra de búsqueda y botón

 input type="text" id="search-text" placeholder="Search.." name="search"> <button type="submit" id="search-button"><i class="fa fa-search" id="search-button"></i></button>

frontend.js

 function executeSearch(){ let searchTerm= document.getElementById('search-text').value; if(!searchTerm){ location.replace('/'); return; } let mainContent= document.getElementById('main-content'); let searchUrl = `/posts/search?search=${searchTerm}`; fetch(searchUrl) .then((data) =>{ console.log(data); }) .catch((err) =>console.log(err)); } const {execute} = require("../../config/database"); let searchButton = document.getElementById('search-button'); if(searchButton){ searchButton.onclick = executeSearch; }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Estoy empezando con esto. Lo siento si no pude ayudar. En lugar de esto:

 if(searchButton){ searchButton.onclick = executeSearch; }

tu podrías intentar:

 searchButton.addEventListener('click',executeSearch());

Estoy editando esto porque, mirando el comentario anterior, creo que no entendí bien tu problema, pero lo dejo aquí, tal vez ayude a alguien.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!