Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

191
Visualizações
creating <li>s in JS

I'm working on some code to create lists based on the time of the day... this would be a really easy thing to just add in HTML, but I'm trying this method for some future-proofing, and to see if I can get it to work. I've looked at several pages on w3, MDN, and right here on StackOverflow, and this is what I've put together, but I can't seem to get it to run properly.

I should also say, I'm really new to programming and this is my first project. I've been slowly building it as I learn new concepts as a way to put them into practice.

Thanks for any help you can offer!

morningMedsList = ['med1', 'med2', 'med3', 'med4', 'med5'];
eveningMedsList = ['med1', 'med2', 'med3', 'med4', 'med5'];

const hour = new Date().getHours();

function listMeds() {
    if (hour >= 19 && hour <= 22) {
        let eveningMeds = document.getElementById('evening-meds-list');
            eveMed = document.createElement('li');
            eveningMedsList.forEach(function (med, index) {
                clone = eveMed.cloneNode();
                clone.textContent = (index +1) + ': ' + med;
                eveningMeds.appendChild(clone);
            });
    }
}

listMeds();
<div id="reminders-pics-container">
                        <div id="pics-box-morning">
                            <p>Morning meds pic</p>
                            <ul id="morning-meds-list">
                            </ul>
                        </div>
                        <div id="pics-box-lunch">
                            <p>Lunch meds pic</p>
                        </div>
                        <div id="pics-box-dinner">
                            <p>Dinner meds pic</p>
                        </div>
                        <div id="pics-box-evening">
                            <p> Evening meds pic</p>
                            <ul id="evening-meds-list">  
                            </ul>
                        </div>
                        <div id="pics-box-blank">
                            <p>No meds</p>
                        </div>
                    </div>

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda