Skip to content

Instantly share code, notes, and snippets.

@jatieu
Created December 27, 2021 10:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jatieu/96d24c466454e38bdf363fb8826c072d to your computer and use it in GitHub Desktop.
Save jatieu/96d24c466454e38bdf363fb8826c072d to your computer and use it in GitHub Desktop.
Wait for an element to load with jQuery (Chờ cho 1 phần tử đã load với jQuery)
//Check
let check = (e, m, t, c) => { //(element, max, timeout, callback)
let i = +m,
loop = () => { $(e).length ? c() : --i && setTimeout(() => { loop() }, t) }
loop()
},
//Process
myFunc = () => { //Do something }
//Usage
check("element", 30, 500, myFunc)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment