这个JS有什么问题

时间:2010-08-26 19:55:41

标签: javascript jquery

firebug抱怨它存在语法错误

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

4 个答案:

答案 0 :(得分:7)

你缺少括号,据说你最好这样写。

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

答案 1 :(得分:4)

您需要在parans中包含 整个 条件语句:

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

答案 2 :(得分:1)

你有 括号错误 ,试试这个:

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

答案 3 :(得分:1)

更正后的表格:(删除了2个括号)

if(document.getElementById(“fromAddress”)。value ==“”|| document.getElementById(“fromAddress”)。value ==“输入地址,城市,方向”){