DEV Community

loading...
Cover image for How to make a library like jquery within 50 lines of code....

How to make a library like jquery within 50 lines of code....

Raghav9official
var Coder => (){ ”always” = true; }
・1 min read

Hi guys,

Ever tried to make a jQuery like library?
It's not that hard to make it!
Here I'll show you in this tutorial...

First create a function (anything basicaly)
I'll take a hashtag like I took in my hashtag library project here=> https://github.com/netopa/hash.js/

function hash(sel){

const self = { //make an object
   element: document.querySelector(sel),
   html: () => {.  //Make a function
       self.element
   },
   hide: () => {
       self.element.style.display = "none"
   },
   show: () => {
       self.element.style.display = ""
   },
   on: (event, callback) => {
       self.element.addEventListener(event, callback)
   }


 }

}
Enter fullscreen mode Exit fullscreen mode

They are a few examples you can even add more of then there

Bonus

Commit in my resporatory in https://GitHub.com/netopa/hash.js

And its homepage is at:
https://netopa.github.io/

Join the organisation:
https://netopa.github.io/join/

That's it for today
STAY TUNED

Discussion (0)