fmpq.com
源代码:
点击运行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Fmpq教程(fmpq.com)</title> </head> <body> <p>点击按钮将数组中的所有值乘以特定数字。</p> <p>乘以: <input type="number" id="multiplyWith" value="10"></p> <button onclick="numbers.forEach(myFunction)">点我</button> <p>计算后的值: <span id="demo"></span></p> <script> var numbers = [65, 44, 12, 4]; function myFunction(item,index,arr) { arr[index] = item * document.getElementById("multiplyWith").value; demo.innerHTML = numbers; } </script> </body> </html>
运行结果