3 ms·
I think the Node querySelector $('selector'), attaching event listeners, getting and setting element width/height
by XCSme 6y ago
I think the Node querySelector $('selector'), attaching event listeners, getting and setting element width/height
- efreak 6y agoMy script template includes some things like `var $=a=>{return document.querySelector(a)}`, `...prototype.evt=(a,b)=>{var e=this.addEventListener(a,b);this.events=this.events||[];this.events.push(e);return e}` and a few other shortcuts. I generally do a mass search and replace to remove them before saving as sometimes i modify them, and conflicting userscripts isn't fun.
- XCSme 6y agoYes, you can replace basic functionality with a few lines of code, but jQuery has more features. For example, jQuery.on('') also works with dynamically created elements. If you want that in vanilla JS you have to write more lines a code, I actually created a library/function for this specific use case: https://github.com/Cristy94/dynamic-listener https://github.com/Cristy94/dynamic-listener