Skip to content

Instantly share code, notes, and snippets.

@yashasvi9199
Created July 13, 2023 16:21
Show Gist options
  • Save yashasvi9199/93f774f12848b54060bf33d2f9a311f7 to your computer and use it in GitHub Desktop.
Save yashasvi9199/93f774f12848b54060bf33d2f9a311f7 to your computer and use it in GitHub Desktop.
Check if the function has already been executed
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.4/jquery.min.js"></script>
</head>
<body>
<button id="first">Click Me Once!</button>
<script>
$("button").click(function() {
if (!localStorage.getItem("validate")) {
alert("Thanks for clicking me !");
localStorage.setItem("validate", "true");
} else {
alert("You can't do that again!!");
}
})
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment