I'm trying to get JavaScript's document.write to work like PHP's echo. For example:
<?php
echo "
<style>
div {
border: 1px solid black;
}
<style>
";
?>
<div> Hello </div>
would work just fine in PHP, and it'll make a border of 1px solid black around the div. However in JavaScript:
<script>
document.write("
<style>
div {
border: 1px solid red;
}
<style>
");
</script>
<div> Hello </div>
it wouldn't work, and it doesn't make a border of 1px solid black around the div. I'm wondering if it's even possible to do the same thing with JavaScript, and if so what am I doing wrong and how to fix it.