Last active
December 23, 2021 05:03
-
-
Save ridhotegar/12eb206c778a8702bd9ca6f568301e14 to your computer and use it in GitHub Desktop.
Disable all onclick on page html with jquery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let clickAct = [] | |
const _do = { | |
disable: () => { | |
let el = $('[onclick]'), count = el.length | |
el.each((i, e) => { | |
$(e).addClass(`click_${i}`) | |
clickAct[i] = $(e).attr('onclick') | |
if(!--count) { el.removeAttr("onclick") } | |
}) | |
}, | |
enable: () => { | |
clickAct.forEach((e, i) => { | |
$(`.click_${i}`).attr('onclick', clickAct[i]) | |
$(`.click_${i}`).removeClass(`click_${i}`) | |
}) | |
} | |
} | |
//-- how to | |
_do.disable() | |
/* yourcode */ | |
_do.enable() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment