JS dQuery

Objective/s:
  • To create your own jQuery library that implements the use of querySelector() and querySelectorAll() methods.

Remember that when you learned jQuery, you used callbacks all the time!  For example, do you remember doing things like this?

$(document).click(function() {
  ...
});

Or how about any of the following?

$('h2, h3').click(function() {
   $('h2, h3').hide();
}
$.get("/...", function(res) {
...
});

Note that in all of these, you were passing a function as an argument to another function.  You were using callbacks!

Now, instead of just using these functions where you were familiar with passing a callback function, it's your turn to create these functions yourself!  This time, instead of using jQuery, we want you to use native Javascript to build these functions.

dQuery.js

Now that you know how to use a callback, let's have you create a javascript library and name it dQuery.js.  Anyone who loads your script could have $query available where they could execute codes such as below.  Note that what we want you to create is essentially a mini library, similar to jQuery, but instead you wouldn't use any jQuery but build all of this from scratch using native Javascript.  Again, please do NOT use jQuery to build this assignment but really see how you could create a library like jQuery, but from scratch.

```

JS Dollar Query

Heading 1

Sample Paragraph 1

Sample Paragraph 2

Please submit your assignment before moving to the next lesson. chevron_left Prev Nextchevron_right