Skip to content

Instantly share code, notes, and snippets.

@Blainegunn
Created February 28, 2018 01:58
Show Gist options
  • Save Blainegunn/90deb788458d3714230e1bf7a9ca412f to your computer and use it in GitHub Desktop.
Save Blainegunn/90deb788458d3714230e1bf7a9ca412f to your computer and use it in GitHub Desktop.
Calculator Exam
<div class="number">1</div>
<div class="number">2</div>
<div class="number">3</div>
<div class="number">4</div>
<div class="number">5</div>
<div class="number">6</div>
<script type="text/javascript">
var numbers = document.querySelectorAll('.number')
Array.from(numbers).forEach(function(element){
element.addEventListener('click', function(){
console.log(element.textContent);
})
})
</script>
<style media="screen">
.number {
display: inline-block;
width: 30%;
background: grey;
color: orange;
font-size: 50px;
border-radius: 15px;
margin: 5px;
text-align: center;
}
body {
text-align: center;
}
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment