JSFiddle - React, Tailwind, and code Playground
by akang2
JavaScript
//Act 9.1 jQuery aaaaah!!
//When we want to grab an element from the webpage (DOM), we use 'document.getElementById()'. However, typing that out a lot gets annoying.
//jQuery solves that annoyance by making it so you just type "$". Yep, the dollar sign, that's it. The "$" is essentially a function, and just like in Javascript, you put a parentheses after you start a function. So, $() by default replaces document.getElementById(). But it's even better because you can target MORE than just ID's. If you want to target a <p> tag, do this: $("p"); Cool huh?! :D
//Since a lot of jQuery is about selecting elements from the webpage (again, also known as the DOM),
//We can also pass in a function inside the $(). It would look like this: $(function(){});
//Why don't we just do $(function){};?
//In regular JS, if we wanted to create and append an HTML element, we would do: var newDiv = document.createElement("div"); document.body.appendChild(div);
//with jQuery, all we need to write is var newDiv = $("<div>bla bla</div>"); $('body').append( newDiv );
//shit, what to write here...