Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

How would you use nodejs and client side javascript in one project? like connect to the DOM of the nodejs web app?

I was just wondering how you can do things like use jquery on a nodejs web app.

2 Answers

Robert Manolis
STAFF
Robert Manolis
Treehouse Guest Teacher

Hi Faysal, great question. You can't use jQuery in Node. JQuery only runs in the browser environment, with client side JS. Node runs on the server, which is a completely different environment. An example of using both Node and client side JS could be a Node or Express app that served HTML or Pug template files along with some client side JS. So the Node or Express app would respond to HTTP requests and send assets over to the client to be run and rendered in the browser. Think about any time you enter a URL into Chrome's address bar. That sends a request to a server somewhere. That could be a server running Node.js. The server reads the request and responds accordingly, sending back the assets you see and interact with in the browser, including the HTML, CSS and client side JS.

Hope that helps shed some light on this. :smiley:

thank you !!!