Tengo 4 íconos en mi barra de menú y cuando presiono fa-plus-square quiero ocultar el div #addPost. Creo que mi JS está bien y no puedo localizar el problema aquí.
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>¡Debería ser getElementById no getElementsById ! Elimina la 's' al final del elemento.