I am using the following function to print out the contents of javascript variables.
function message (){
$("#description").html("Candidate " + (lowest+1) + " was the first to get eliminated ending on " + results[lowest][0]+ "%");
}
This correctly works as expected, however if i try this:
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]+ "%");
}
This obviously doesn’t work. The second message overwrites the text of the first message. What is the proper way displaying both messages.
keep DOM manipulation as few as possible for the sake of the performance (it will save you from unnecessary page repaints): just use a variable to contain all your strings and do the insertion once so to avoid multiple expensive calls to
jQueryfunction.