简体   繁体   English

Javascript警告框未显示

[英]Javascript Alert box not displaying

Ok so I still pretty new to programming but I can not wrap my head around why this code on jsbin doesn't work. 好的,所以我对编程还是很陌生的,但是我无法解决为什么jsbin上的代码不起作用的原因。 I would think an alert box should pop up with with first value of the array which is the string "red" but nothing happens. 我认为应该弹出一个警告框,其中包含数组的第一个值,即字符串“ red”,但什么也没有发生。 I don't understand what the warnings are telling me either. 我也不明白警告在告诉我什么。 I am sure its something simple but I just can't get it. 我敢肯定这很简单,但我做不到。

Live demo: http://jsfiddle.net/XZbnr/ 现场演示: http//jsfiddle.net/XZbnr/

Code: 码:

var colors = [“red”, “blue”, “green”]; 
alert(colors[0]);

Looks like you have some special characters in there: 看起来您那里有一些特殊字符:

var colors = [“red”, “blue”, “green”]; 

Those quotes appear to be pasted from Microsoft Word, or similar. 这些引号似乎是从Microsoft Word或类似语言粘贴的。

Replace them with " and it will work: 将它们替换为“,它将起作用:

var colors = ["red", "blue", "green"]; 
alert(colors[0]);

http://jsfiddle.net/XZbnr/1/ http://jsfiddle.net/XZbnr/1/

用普通引号替换“:”或“

Looks like you're using the wrong kind of quotation marks. 好像您使用了错误的引号。 Try just using " or ' 尝试仅使用“或”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM