$ sign to pick up an element and do stuff to it.
document.querySelector multiple times in an application. Well, guess what, there's an easy way to just bind that
$ sign to your document's
Here's how you go about it.
const $ = document.querySelector.bind(document); const $$ = document.querySelectorAll.bind(document);
Now you can use the following:
// Change the background color of a class. $('.class').style.background="#BADA55"; // Change the inner HTML of an ID. $('#id').innerHTML="<span>Cool beans!</span>"; // Select all images on the webpage. $$('img') // Print the image addresses for all the images on a webpage. $$('img').forEach(img => console.log(img.src))
Awais.dev@mrahmadawais🔥 Today's #OneDevMinute is for those who miss the simplicity of jQuery but now have to do `document.querySelector` again and again — coz who uses jQuery in 2019.
⚛️ Guess what you can bind the querySelector to $.
const $ = document.querySelector.bind(document)
🙏 Retweet :)15:01 PM - 02 Apr 2019
Use your code for good and have fun! :)
Nginx is a great piece of software that allows you to easily wrap your application inside a reverse-proxy, which can then handle server-related aspects, like SSL and caching, completely transparent to the application behind it.