<!DOCTYPE html><html><head> <meta charset="UTF-8"> <title>ESP8266 LED Control</title> <style> </style></head><body> <h1>ESP8266 LED Control</h1> <input type="range" min="0" max="255" value="0" id="brightnessSlider" oninput="onput_function();"> <p id="brightnessValue">Brightness: 0</p> <script> function onput_function() {var slider = document.getElementById("brightnessSlider"); var output = document.getElementById("brightnessValue"); output.innerHTML = "值为" + this.value; }); function sendBrightness(value) { var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { console.log("Brightness set to: " + value); } }; xhttp.open("GET", "/brightness?value=" + value, true); xhttp.send(); } </script>body></html>把这段代码整理成网页格式
时间: 2024-03-18 12:43:52 浏览: 13
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>ESP8266 LED Control</title>
<style>
</style>
</>
<body>
<h1>ESP8266 LED Control</h1>
<input type="range" min="0" max="255" value="0" id="brightnessSlider" oninput="onput_function();">
<p id="brightnessValue">Brightness: 0</p>
<script>
function onput_function() {
var slider = document.getElementById("brightnessSlider");
var output = document.getElementById("brightnessValue");
output.innerHTML = "值为" + this.value;
});
function sendBrightness(value) {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
console.log("Brightness set to: " + value);
}
};
xhttp.open("GET", "/brightness?value=" + value, true);
xhttp.send();
}
</script>
</body>
</html>