我正在使用以下函數打印出javascript變量的內容。如何使用jQuery正確打印HTML中的變量
function message(){
$("#description").html("Candidate " + (lowest+1) + " was the first to get eliminated ending on " + results[lowest][0]+ "%");
}
這正確正常工作,但是如果我試試這個:
function message(){
$("#description").html("Candidate " + (lowest+1) + " was the first to get eliminated ending on " + results[lowest][0]+ "%");
$("#description").html("Candidate " + (lowest2+1) + " was the second to get eliminated ending on " + results[lowest2][0]+ "%");
}
這顯然是行不通的。第二條消息覆蓋第一條消息的文本。什麼是正確的方式顯示這兩個消息。