有问题的javascript数组?
我的javascript有问题。当作为html运行时,按钮的功能不起作用 HTML:有问题的javascript数组?,javascript,html,arrays,sorting,Javascript,Html,Arrays,Sorting,我的javascript有问题。当作为html运行时,按钮的功能不起作用 HTML: <p>Click the button to sort the array.</p> <button id=“buttonOne” onclick=“myFuntion()”>Try it</button> <p id="demo"></p> <button id = “ButtonTwo” onclick=“myFunction(
<p>Click the button to sort the array.</p>
<button id=“buttonOne” onclick=“myFuntion()”>Try it</button>
<p id="demo"></p>
<button id = “ButtonTwo” onclick=“myFunction()”>Count the Number of products!</button>
<p id=‘demo2”></p>
var fruits = ["apple", "banana", "mango", "orange","avocado"];
document.getElementById("demo").innerHTML = fruits;
var buttonOne = document.getElementById("buttonOne");
var buttonTwo = document.getElementById("buttonTwo");
buttonOne.addEventListener("click", function() {
fruits = fruits.sort();
document.getElementById("demo").innerHTML = fruits;
});
buttonTwo.addEventListener("click", function() {
length = fruits.length;
document.getElementById("demo2").innerHTML = length;
});
如果有人能看一看这个,也许会建议它有什么问题?数一数产品的数量!
<button id = “ButtonTwo” onclick=“myFunction()”>Count the Number of products!</button>
var buttonTwo=document.getElementById(“buttontw”)
id是B,getElementById是B更改其中一个
并且myFunction不存在Remove
onclick=“myFunction()”
。没有myFunction或myFunction。HTML中的引号类型错误。使用“
或”
,而不是“
和”
。编辑代码时,请关闭文本编辑器中的“智能引号”。