Calculator Tools Calculator Tools
Create

Fun Button Slots

Nov 12, 2023

About this app

A fun and exciting game where you press numbered buttons to spin a slot machine.

Fun Button Slots

Related apps

Put this on your site

Source

                    <html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1">

<title>Fun Button Slots</title>
<meta name="description" content="A fun and exciting game where you press numbered buttons to spin a slot machine.">
<meta name="keywords" content="button, slots, game, fun, exciting, random">

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">

<script type="text/javascript">
try {
document.addEventListener("DOMContentLoaded", function() {
var buttons = Array.from({length: 45}, (_, i) => i + 1);
var resultsArea = document.getElementById('results');

buttons.forEach(function(buttonNumber) {
var button = document.createElement('button');
button.innerHTML = buttonNumber;
button.addEventListener('click', function() {
var result = Math.floor(Math.random() * 3) + 1;
resultsArea.innerHTML = 'Button ' + buttonNumber + ' result: ' + result;
});
document.getElementById('buttons').appendChild(button);
});
});
} catch (error) {
throw error;
}
</script>

<style>
#buttons button {
margin: 5px;
background-color: #00c853;
color: white;
border: none;
padding: 10px;
cursor: pointer;
transition: background 0.3s;
}
#buttons button:hover {
background-color: #4caf50;
}
</style>
</head>
<body>
<div id="main-container" class="container">
<div id="buttons"></div>
<div id="results" style="margin-top: 20px;"></div>
</div>
</body>
</html>