I'm trying to build a replica of the Simon game with HTML, CSS and Javascript.
The design I have is nowhere near the final state, but I have the basic layout in place:
Each of the colored buttons (Green, Red, Yellow and Blue) have respective click events and I'm testing them out with console.log statements.
Here is the relevant section from the code:
$(document).ready(function() {
$('.center-buttons').click(function() {
event.stopPropagation();
console.log("Inner Click!");
});
$('#top-left').click(function() {
console.log('left click.');
});
$('#top-right').click(function() {
console.log('right click.');
});
$('#bottom-left').click(function() {
console.log('bleft click.');
});
$('#bottom-right').click(function() {
console.log('bright click.');
});
});
.main-area {
height: 700px;
width: 700px;
border-radius: 50%;
background-color: ;
margin: 0px auto;
padding: 20px;
}
.wrapper {
position: relative;
top: -5px;
}
.center-buttons {
height: 370px;
width: 370px;
border: 15px solid #444;
border-radius: 50%;
background-color: black;
margin: 0px auto;
position: relative;
top: -550px;
}
#top-row {
display: flex;
}
#bottom-row {
display: flex;
}
.main-button {
height: 310px;
width: 310px;
border: 20px solid #444;
}
#top-left{
background-color: #00994d;
border-radius: 100% 0 0 0;
right: 50%;
margin: 0px 5px 5px 0px;
}
#top-right{
background-color: #990000;
left: 50%;
border-radius: 0 100% 0 0;
margin: 0px 0px 5px 5px;
}
#bottom-left {
background-color: yellow;
left: 50%;
border-radius: 0 0 0 100%;
margin: 5px 5px 0px 0px;
}
#bottom-right {
background-color: #004d99;
left: 50%;
border-radius: 0 0 100% 0;
margin: 5px 0px 0px 5px;
}
<div class = 'main-area'>
<div class = 'wrapper'>
<div id = 'top-row'>
<div id = 'top-left' class = 'main-button'></div>
<div id = 'top-right' class = 'main-button'></div>
</div>
<div id = 'bottom-row'>
<div id = 'bottom-left' class = 'main-button'></div>
<div id = 'bottom-right' class = 'main-button'></div>
</div>
</div>
<div class = 'center-buttons'></div>
</div>
In the CSS, each colored button has a thick gray border.
The main question: When the borders of any of the buttons are clicked, is there a way to prevent the click event for the respective button from happening.
Thanks.