đź’»
Cheatsheets
  • Most Useful Command Line Tools: 50 Cool Tools to Improve Your Workflow, Boost Productivity, and More
  • 7_tips_to_reverse_engineer_javascript
  • Configuring a Repl
  • How to create your command-line program (CLI) with NodeJS and Commander.js | by Duc N. | JavaScript
  • replit Node.JS 24/7 Project Hoster
  • cheatsheets
  • Alacritty, Tmux, and Vim
  • amethyst
  • Android
  • Installing Arch Linux
  • Arch Linux
  • aria2
  • bin
  • bspwm
  • Chocolately Notes
  • command_line_pipes
  • CSS Grid
  • curl
  • The curl guide to HTTP requests
  • Docker
  • Easymotion
  • Emmet
  • Favorite figlet fonts
  • FFMPEG
  • figlet
  • File Serve
  • File Transfer
  • fish shell
  • Front End Dev Links
  • How to use Git.io to shorten GitHub URLs and create vanity URLs
  • Git
  • Downloading a Tarball from GitHub
  • Make Infinite Gmail Addresses For One Inbox
  • How To Use GPG on the Command Line
  • guide_to_fish_completions
  • Homebrew
  • How to clean Arch Linux
  • HTML5 Boilerplate
  • Install
  • All the keyboard shortcuts you’ll ever need for Safari on iPad
  • iosevka
  • iPhone
  • ish (iOS)
  • Javascript Notes
  • jq
  • Jupyter Notebooks
  • Lettering
  • lf-wiki
  • lf
  • Command Line
  • Adding a swapfile after a clean installation without swap partition
  • mac_bluetooth_issues
  • Mac Terminal
  • maim
  • markdown-sample
  • Markdown Notes
  • Images in README.md Markdown Files
  • Organizing information with tables
  • md_cheatsheet
  • NiftyWindows Help
  • nix
  • Justin Restivo - A Portable Text Editor: Nix <3 Neovim
  • NPM
  • neovim configuration
  • Pastery
  • Powershell
  • Table of Basic PowerShell Commands | Scripting Blog
  • Powershell Modules
  • Puppeteer
  • Python
  • rclone-colab
  • replit
  • Hi there, I'm Raju Ghorai - a.k.a. [coderj001]
  • Scriptable
  • Servor
  • Replacing Postlight’s Mercury scraping service with your self-hosted copy
  • Shell Scripts
  • skhd
  • Spicetify
  • SSH
  • SurfingKeys
  • tar
  • Terminal Web Browser Docker
  • Text Generators
  • tmux shortcuts & cheatsheet
  • unicode
  • VIM
  • VIM Diff
  • vi Complete Key Binding List
  • 8 Essential Vim Editor Navigation Fundamentals
  • Vim Shortcut Keys
  • Vite
  • VNC
  • web-servers
  • Web Server
  • Windows Command Line
  • Writeguard
  • WSL Cheatsheet
  • youtube-dl
  • zsh Plugins
  • zspotify
Powered by GitBook
On this page

Was this helpful?

Javascript Notes

I needed this because I wanted the callback function to be more complex than a line or two: ```javascript const makeHideHandler = (element) => { // higher order function return () => { // event handler function element.hidden = true; / action to perform }; }; hider.addEventListener('click', makeHideHandler(hider)); ``` > However, the real strength of the higher order function approach becomes visible if you have more than one element that should hide the same (or other!) element(s). Consider the following: Let's say, you have multiple buttons that, when pressed, should hide the same element. It's easy peas with `makeHideHandler`: ```javascript // grab all "button" elements const hideButtons = document.querySelectorAll('.hide-button'); // grab the element to hide const elemToHide = document.querySelector('.hide-me'); // make the handler, pass in the element that should be hidden const hideHandler = makeHideHandler(elemToHide); // add listeners to the buttons hideButtons.forEach((button) => { button.addEventListener('click', hideHandler); }); ``` Or to create buttons that hide themself after pressing: ```javascript const hideButtons = document.querySelectorAll('.hide-button'); hideButtons.forEach((button) => { button.addEventListener('click', makeHideHandler(button)); // <-- pass in the button element }); --- ## Javascript DOM Manipulation tutorial: https://m.youtube.com/watch?v=y17RuWkWdn8 `innerText` returns plain text `textContent` returns all text with formrtting use `append` and not appendChild append can take multiple items and also strings `innerHtml` will let you use html in strings remove() deletes from DOM .id or .title will give the attribute for example setAttribute('id', 'newId') removeAttribute('id') .classList does class stuff .classList.toggle toggles on and off .style is for css styles example .style.backgroundColor = "red"; .style.display = "block";
Previousish (iOS)Nextjq

Last updated 2 years ago

Was this helpful?