Spaces:
Sleeping
Sleeping
File size: 2,001 Bytes
43e5360 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
<!DOCTYPE html>
<html>
<head>
<title>Button Demo</title>
<style>
body {
font-family: Arial, sans-serif;
max-width: 800px;
margin: 0 auto;
padding: 20px;
text-align: center;
}
.button {
display: inline-block;
padding: 10px 20px;
margin: 10px;
font-size: 16px;
cursor: pointer;
text-align: center;
text-decoration: none;
outline: none;
color: #fff;
background-color: #4CAF50;
border: none;
border-radius: 5px;
box-shadow: 0 5px #999;
}
.button:hover {background-color: #3e8e41}
.button:active {
background-color: #3e8e41;
box-shadow: 0 2px #666;
transform: translateY(4px);
}
.blue {background-color: #008CBA;}
.blue:hover {background-color: #0073aa;}
.blue:active {background-color: #0073aa;}
#result {
margin-top: 20px;
padding: 10px;
border: 1px solid #ddd;
border-radius: 5px;
min-height: 100px;
}
</style>
</head>
<body>
<h1>Button Demo</h1>
<button class="button" onclick="handleAction('action1')">Button 1</button>
<button class="button blue" onclick="handleAction('action2')">Button 2</button>
<div id="result">
<p>Result will appear here...</p>
</div>
<script>
function handleAction(action) {
fetch('/' + action, {
method: 'POST'
})
.then(response => response.json())
.then(data => {
document.getElementById('result').innerHTML = `<p>${data.result}</p>`;
})
.catch(error => {
document.getElementById('result').innerHTML = `<p>Error: ${error}</p>`;
});
}
</script>
</body>
</html> |