Now to get an element in jQuery lets start with something basic, document and body. To use the document in jQuery you run this:
This immediately retrieves the document so you can use it as a jQuery object. The same thing goes for the body of the document:
Now for something slightly harder. If you want to retrieve an element by ID, rather than use getElementById as used in vanilla JS you would use a # and the element id as shown here:
The prefixes are exactly like in css with .class and #id. Here are a couple functions you might need in web development:
$("#demo").val(); // The value of the element such as in an input$("#demo").text(); // The text inside of an element$("#demo").html(); // The html inside of an element$("#demo").attr("data-demo"); // The value inside of an attribute such as data-demo$("#demo").css('display', 'none') // Manipulate the element's css style
In all, elements in jQuery are easy to work with and make web development faster in less lines of code.