Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

140
Vistas
CSS3 Animated Search Box in react not working

I am trying to create the following item for my react project http://demo.icanbecreative.com/css3-animated-search-box/ using this reference tutorial https://icanbecreative.com/article/css3-animated-search-box/. but I am having a problem trying to implement the following function

function searchToggle(obj, evt){
    var container = $(obj).closest('.search-wrapper');
        if(!container.hasClass('active')){
            container.addClass('active');
            evt.preventDefault();
        }
        else if(container.hasClass('active') && $(obj).closest('.input-holder').length == 0){
            container.removeClass('active');
            // clear input
            container.find('.search-input').val('');
        }
}

Because it uses JQuery, so I want to convert this function to be able to execute it inside my code. Try to hide the element and show it dynamically every time you press the button as follows

const [showInput, setShowInput] = useState(false);

<div className="search-wrapper">
     <div className="input-holder">
          <button className="search-icon"  onClick={()=>setShowInput((p) => !p)}><span></span></button>
               {showInput &&   <input type="text" className="search-input" placeholder="Type to search" /> }
           </div>
      <span className="close" onClick={displaySearchToggle}></span>
</div>

But it is not working.but it is not working, the button appears correctly but when pressed it does not show the input

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda