Wednesday 24 June 2020

Add JS functionalities to a nodejs express app (slideshow)

I am new to nodejs and I am working on a milestone project. I am using NodeJS, Express, and MongoDB. I had vanilla JS code that was retrieving dummy data and manipulating the HTML through the DOM. I understand I cannot use DOM through an express app. Where would I begin to do the same thing with express? I want to retrieve data from mongoDB and when I click a button on my html retrieve post[i].title and post[i].contentfunction currentPost(n) { post1= '

Post 1

"Lorem ipsum dolor"

'; if (n == 0) { document.getElementById("containerBlogPost").innerHTML = post1; } else if (n == 1){ document.getElementById("containerBlogPost").innerHTML = post2; } else if (n == 2){ document.getElementById("containerBlogPost").innerHTML = post3; } else if (n == 3){ document.getElementById("containerBlogPost").innerHTML = post4; } } On an event I was using that data to upload my html using the DOM. I don't need ridiculous details but I need guidance. I have been struggling with this all day.

Submitted June 25, 2020 at 01:59AM by Prestigious_chestnut

No comments:

Post a Comment