2010-08-26 53 views
0

Firebug是抱怨它有一個語法錯誤什麼錯這個JS

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

您應該在問題中多加一些代碼,以便我們可以在此處獲得一些上下文。假設在{後面有更多的代碼,你可以放入類似{...}的東西,所以我們知道這不是問題的一部分。示例代碼爲+ 1 + – Mnebuerquo 2010-08-26 20:02:33

回答

7

你缺少的括號,這樣說你最好這樣寫它。

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

你需要用的整個條件語句中parans:

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

+1 – derekerdmann 2010-08-26 19:59:47

1

你有括號的不匹配,試試這個:

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

更正表格:(刪除2個圓括號)

if(document.getElementById(「fromAddress」)。value ==「」|| document.getElementById(「fromAddress」)value ==「輸入地址,城市,方向」){