Skip to content

Instantly share code, notes, and snippets.

@Shakil-Shahadat
Last active June 20, 2024 03:51
Show Gist options
  • Save Shakil-Shahadat/323e1bdd0d0f7f354b077991641c10b0 to your computer and use it in GitHub Desktop.
Save Shakil-Shahadat/323e1bdd0d0f7f354b077991641c10b0 to your computer and use it in GitHub Desktop.
[ Delete ] Functions to shorten querySelector* calls in JavaScript
function qs( cls )
{
return document.querySelector( cls );
}
function qsa( cls )
{
return document.querySelectorAll( cls );
}
// Examples
qs( '.box' ).innerText = 'Hello World!';
qsa( '.box' )[ 0 ].innerText = 'Hello Universe!';
@Shakil-Shahadat
Copy link
Author

Shakil-Shahadat commented Dec 18, 2021

ToDo

  • Move this to miscellaneous.js. [ Done ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment