Skip to content

Instantly share code, notes, and snippets.

@cferdinandi
Created September 20, 2022 15:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save cferdinandi/3fea0c4576e98ea84b1d06faf3a10b86 to your computer and use it in GitHub Desktop.
Save cferdinandi/3fea0c4576e98ea84b1d06faf3a10b86 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Inspecting JavaScript</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style type="text/css">
body {
margin: 2em auto;
max-width: 40em;
width: 88%;
}
button {
transition: transform ease-in 200ms;
}
</style>
</head>
<body>
<p><button>Activate Me</button></p>
<script src="script.js"></script>
</body>
</html>
// Get the button
let btn = document.querySelector('button');
// Do some events
btn.addEventListener('click', function () {
console.log('Activated');
});
btn.addEventListener('mouseenter', function () {
btn.style.transform = 'scale(2)';
});
btn.addEventListener('mouseleave', function () {
btn.style.transform = '';
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment