<!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 = "值为" + slider.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>和<!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 17:41:49 浏览: 371
HTML参考手册
不完全一样,第二个 HTML 代码存在语法错误。在第二个代码中,`onput_function()` 函数的语法是不正确的,应该是 `oninput_function()`。此外,`onput_function()` 函数的代码也被修改了,导致其与第一个代码不同。在第二个代码中,`onput_function()` 函数的代码是:
```
function onput_function() {
var slider = document.getElementById("brightnessSlider");
var output = document.getElementById("brightnessValue");
output.innerHTML = "值为" + this.value;
});
```
这段代码多了一个右括号 `)`,而且没有与前面的左括号 `(` 匹配。正确的代码应该是:
```
function oninput_function() {
var slider = document.getElementById("brightnessSlider");
var output = document.getElementById("brightnessValue");
output.innerHTML = "Brightness: " + slider.value;
}
```
除此之外,两个 HTML 代码是完全一样的。
阅读全文