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

259
Vistas
Onclick function on font awesome icon

I have 4 icons in my menu bar and when I press the fa-plus-square I want to hide the div #addPost. I believe my JS is fine and cannot locate the issue here

function showPost(){
    let add = document.getElementsById("addPost")
    if (add.style.display === "none" ){
        add.style.display = "block"
    } else {
        add.style.display = "none"
    }
}
        <ul class="icons"> 
            <li>
                <i class="fas fa-home" style="color: black;"></i>
            </li>
            <li>
                <i class="fas fa-inbox"></i>
            </li>
            <li>
                <i class="far fa-plus-square" onclick="showPost()"></i>
            </li>
            <li>
                <i class="far fa-heart"></i>
            </li>
        </ul>
        
 <div id="addPost" >
        <div class="title">Create new post
            <i class="fas fa-times"></i>
        </div>
        <div class="name">
            <input type="Name" placeholder="Username" required>
        </div>
        <div class="post">
            <textarea placeholder="What's on your mind?" ></textarea>
        </div>
        <div class="comment">
            
        </div>
    </div>

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

It should be getElementById not getElementsById! Remove the 's' at the end of element.

about 4 years ago · Juan Pablo Isaza Denunciar
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