Author name: Aryan Yadav

Using EJS to Template Your Node Application

What is EJS? EJS (Embedded JavaScript) is a simple templating language that lets you generate HTML markup with plain JavaScript. It allows you to include dynamic content and logic in your HTML pages without the overhead of a full client-side framework. Setting Up Your Node Application First, ensure that you have Node.js and npm installed …

Using EJS to Template Your Node Application Read More »

Changing the CSS Property of an HTML Element in the JavaScript DOM

Introduction to DOM Manipulation Manipulating the DOM is key to creating interactive web pages. JavaScript allows you to change the style of HTML elements on the fly without refreshing the page. A Practical Example: Changing a Div’s Background Color Let’s add a button and a div to our index.ejs file, and then use JavaScript to …

Changing the CSS Property of an HTML Element in the JavaScript DOM Read More »

Displaying an Image on a Web Page using Node.js and Express

Serving Static Files To display images or any other static files (CSS, JavaScript, etc.), you need to instruct Express to serve a static directory. Let’s create a folder called public: mkdir public Configuring Express for Static Assets Update your app.js to serve static files from the public directory: // Serve static files from the ‘public’ …

Displaying an Image on a Web Page using Node.js and Express Read More »

Scroll to Top