0
私のジャバスクリプトに問題があります。ボタンのhtml機能として動作しているときは動作しません。問題のあるjavascript配列ですか?
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()”>Count the Number of products!</button>
<p id=‘demo2”></p>
はJavaScript:
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;
});
誰かがこれを見て取り、おそらくそれと間違っているものを提案することができれば?
が存在します。 * myFuntion *または* myFunction *はありません。 – RobG
HTMLに引用符のタイプが間違っています。 '' 'や' ''ではなく、 '' 'や' ''を使用してください。コードを編集するときは、テキストエディタで "スマート引用符"をオフにしてください。 – Barmar