Reputation: 1626
I want to append a div(dynamically created) inside a div. I get this error when i append a div. But if i try to append a string it works without any issue. I dont understand the reason behind this. I don't see anything wrong with my syntax as well. The below one cause error
$("#scheduled_bar_panel_col").append(
"<div class='col-lg-3 col-md-4 col-sm-6 col-xs-8' id = 'panel_column'>
</div>"
);
But this works perfect
$("#scheduled_bar_panel_col").append(
"Hello"
);
Let me know what is the reason behind this and how to solve this
Upvotes: 1
Views: 1510
Reputation: 68675
Because ""
doesn't support multi lines. Use `` for them if you use modern JavaScript ES6
Browser compatibility
`<div class='col-lg-3 col-md-4 col-sm-6 col-xs-8' id = 'panel_column'>
</div>`
Or use to separates strings
and concatenate them.
"<div class='col-lg-3 col-md-4 col-sm-6 col-xs-8' id = 'panel_column'>" +
"</div>"
Upvotes: 5
Reputation: 48417
You need to use +
symbol at the end of line:
$("#scheduled_bar_panel_col").append(
"<div class='col-lg-3 col-md-4 col-sm-6 col-xs-8' id = 'panel_column'>" +
"</div>"
);
Upvotes: 2