2

I have

$('body').append("<div id=block> <center> <input type=submit value=submit id=sub> </center> <p id=display_message> </p> </div>");

Instead of this I want to write the code inside append() in an indented manner like this

$('body').append("<div id=block> 
                     <center> <input type=submit value=submit id=sub> </center> 
                     <p id=display_message> </p>
                  </div>");

but it shows illegal token error. Please help

2

2 Answers 2

6

you need to put \ after end of each line

$('body').append("<div id=block>\
                 <center> <input type=submit value=submit id=sub> </center>\
                 <p id=display_message> </p>\
              </div>");

Working Demo

Sign up to request clarification or add additional context in comments.

Comments

0

try this code

var content = "<div id=block>"+
                     "<center> <input type='submit' value='submit' id='sub'> </center> "+
                     "<p id='display_message'> </p>"+
                  "</div>"
$('body').append(content);

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.