Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save djD-REK/423cd380bab1f1f26448554d0fa6ccfe to your computer and use it in GitHub Desktop.
Save djD-REK/423cd380bab1f1f26448554d0fa6ccfe to your computer and use it in GitHub Desktop.
// Load jQuery, equivalent to having the <script> tag on the page
// <script src="https://code.jquery.com/jquery-3.5.0.js"></script>
const loadScript = async (url) => {
const response = await fetch(url)
const script = await response.text()
eval(script) // or Function(script)
}
const scriptUrl = "https://code.jquery.com/jquery-3.5.0.js"
loadScript(scriptUrl)
// In the browser console, you need to enter and run the above commands to load
// jQuery first, separately, before you can actually use it in the console:
// Select all <div> elements on the page
const jQueryDivs = $("div")
// Apply CSS styles to the selected <div> elements
jQueryDivs.css("border", "3px solid orange")
// As a one-liner:
$("div").css("border", "3px solid orange")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment