What is the meaning of "$" in index html <script>

I was going through a tutorial on building a messaging app with node, express, sockets io and mongoose but decided to skip the mongoose set up and decided to go with storing the messages in a json file on my PC for now. I filled a json file with some sample messages and had the server return them on GET request. Then i got to the section where front-end is connected to back-end with in index html and i noticed the “$”. After some reaserch i found out its usually used with jQuerry so my guess is that mongoose uses jQuery but I am not sure. Here is the code:

the localhost/messages is changed because forum kept throwing “You cannot post a link to that host” but its localhost port 3000 / messages

$(() => {
          name: $("#name").val(), 
function addMessages(message){
      <h4> ${message.name} </h4>
      <p>  ${message.message} </p>`)
function getMessages(){
  $.get(‘localhost/messages', (data) => {
function sendMessage(message){
   $.post(‘localhost/messages', message)

It doesn’t allow me to post a link to the tutorial but the name is: " How to build a real time chat application in Node.js using Express, Mongoose and Socket io"

I would like to understand better what the $ means and if i can substitute it with something or write all of the code differently to not use it. If it is the second option some general guidance would be nice (Links to articles/docs, tips or code. Any help is much appreciated). Thank you.

All selectors in jQuery start with the dollar sign and parentheses: $().

This article seems to cover what you are looking for.
jQuery selectors

Does that help?

Happy coding! :slightly_smiling_face:

1 Like

Thank you, it does help. I completely missed the part of the post where jQuery is being added. Only after ctrl + f jQuery i found it. Thank you again.

Pleasure. Enjoy the article and good luck with your project.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.