0

In the following code some concatenation is needed to put all the lines into PlayersDetail variable so that a div named PlayersList can be appended.

var onlineStatus="online";
PlayersDetail='Here is some text before if statement.<br>'
if (onlineStatus==="online"){
   'I am online.<br>'
}
'here is some text after if statement.'
$("#PlayersList").append(PlayersDetail);

1 Answer 1

1

You need to use concatenation operator

var onlineStatus = "online";

PlayersDetail = 'Here is some text before if statement.<br>'
if (onlineStatus === "online") {
    //use concatenation operators
    PlayersDetail += 'I am online.<br>'
    //same as 
   // PlayersDetail = PlayersDetail + 'I am online.<br>'
}
//use concatenation operators
PlayersDetail += 'here is some text after if statement.'

$("#PlayersList").append(PlayersDetail);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.