2017-04-09 140 views
1
function bj(numa,numb){ 
    if(numa>numb){ 
     alert(numa); 
    } 
    else if(numa==numb){ 
     alert(numa,numb); 
    } 
    else{ 
     alert(numb); 
    } 
} 

我的意思是,在上面的函數中,當兩個數相等時,彈出窗口會出現兩個值。我可以這樣做嗎?可以同時顯示兩個參數嗎?

+1

將它們連接起來.... – epascarello

+0

'否則,如果(NUMA ==麻木){ 警報(NUMA + 「​​」 +麻木); }' – 2017-04-09 12:54:44

+0

非常感謝你 – helloworld

回答

1

你需要將它們串聯

alert(numa + "," + numb); 
alert(numa + "\n" + numb); 
+0

哇,謝謝,這是原創啊,謝謝 – helloworld

1

根據你想顯示你可以做一些像下面

function bj(numa,numb){ 
    if(numa>numb){ 
     alert(numa); 
    } 
    else if(numa==numb){ 
     alert(numa + " = " + numb); 
    } 
    else{ 
     alert(numb); 
    } 
} 

什麼這將顯示如下,如果NUMA和麻木是12

12 = 12

+0

哇,謝謝你,好難朋友 – helloworld

1

你可以連接它們:

alert('number1: ' + numa + ' number2: ' + numb); 
+0

哇,謝謝,這是原創啊 – helloworld

+0

當然,樂意幫忙。 –

+0

o(^▽^)o hh.thanks。 – helloworld

相關問題