Trying to get a grip on CoffeeScript and jQuery by doing the Code School CoffeeScript course.
One of the excerpts used is $("<li>" + name + "</li>"). I managed to figure out that $ is an alias for jQuery (right?), so I guess this means we’re calling the jQuery function with a string (name is a string, surrounded by two literals).
So… what does the jQuery function do on its own? Tried looking at api.jquery.com, having trouble figuring it out. Thank you!
In this instance you are using jQuery to create a DOM element.
An
<li>with some (text I’m assuming) that is in the variablenameThe structure for creating DOM elements with jQuery is:
Check out these jQuery Docs to read more about the jQuery selector.
As we can see in your example we only pass html.
$("<li>" + name + "</li>")