不明白我是如何得到这个答案的

时间:2017-02-21 17:32:36

标签: javascript html

我需要回答如下问题:

例如,可以在电子商务网站上设置一系列产品,如下所示。

var products = ["Printer","Tablet","Router"]; 

(i)设置一个数组以包含上面显示的项目,以及您选择的一些额外内容。

<!DOCTYPE html>
<html>
    <body>
        <p id="How to set up and Array with items in HTML"></p>

        <script>
            var Items = ["Printer", "Tablet", "Router","Headset","Keyboard","Mouse"];
            document.getElementById("demo").innerHTML = Items;
        </script>
    </body>
</html>

1 个答案:

答案 0 :(得分:0)

您将id设置为"How to set up and Array with items in HTML"而不是"demo"

&#13;
&#13;
<html>
<body>

<p id="demo"></p>

<script>
var Items = ["Printer", "Tablet", "Router","Headset","Keyboard","Mouse"];
document.getElementById("demo").innerHTML = Items;
</script>

</body>
</html>
&#13;
&#13;
&#13;