DEV Community

loading...
Cover image for Simple-Logic-Behind-Jquery

Simple-Logic-Behind-Jquery

Mr.Morsalin
Full stack web developer , specializiing in mostly JS, but also write Python, PHP and some other stuff.
・1 min read
// make  function with make($)
const $ = (d) => {
// make object
  const self = {
      element:document.querySelector(d),
      html:()=> self.element,
      hide:()=> self.element.style.display="none",
      show:()=> self.element.style.display="",
      click:(event,callback)=>self.element.addEventListener(event,callback),
  };
// return object
  return self
};

// final result
$('body').click('click',()=>console.log('click'))
Enter fullscreen mode Exit fullscreen mode

Discussion (0)