简体   繁体   English

这个JS怎么了

[英]whats wrong with this JS

firebug is complaining its there is a syntax error 萤火虫抱怨它存在语法错误

if (document.getElementById("fromAddress").value == "") || 
(document.getElementById("fromAddress").value == "Enter Address, City, Directions") {   

You are missing the parenthesis, that being said you are better off writing it like this. 您缺少括号,也就是说您最好这样写。

var from = document.getElementById("fromAddress").value;
if (from  === "" || from  === "Enter Address, City, Directions") { 

You need to wrap the entire conditional statement in parans: 您需要将整个条件语句包装在parans中:

if ( (blah) || (blah) )
   ^                  ^
{
  // as you were
}

You have mis-match of parenthesis , try this: 的括号不匹配 ,请尝试以下操作:

if ((document.getElementById("fromAddress").value == "") || 
(document.getElementById("fromAddress").value == "Enter Address, City, Directions")){...}

Corrected form: (removed 2 parentheses) 更正形式:(删除了2个括号)

if (document.getElementById("fromAddress").value == "" || document.getElementById("fromAddress").value == "Enter Address, City, Directions") { 如果(document.getElementById(“ fromAddress”)。value ==“” || document.getElementById(“ fromAddress”)。value ==“输入地址,城市,路线”){

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

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