0

I've a variable having multi line text like follows. The variable value comes from db.

<?php   
$text = "db
value
in
multiline";
?>

After running some logic, I need to append this to a div element. For that I've written like follows

<div id ="getme"></div>

<script>
document.getElementById('getme').innerHTML = "<pre><?php print $text;?></pre>";
</script>

If I run the above code it throws an error in console saying

SyntaxError: unterminated string

So how do I handle pre tag in JavaScript/jQuery ?

Krishna Mohan
  • 1,503
  • 3
  • 22
  • 28

0 Answers0