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

Pragya Sharma
  • 94
  • 1
  • 2
  • 9

2 Answers2

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

Milind Anantwar
  • 81,290
  • 25
  • 94
  • 125
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);