It sounds like you're talking about a script that uses document.write
to output content synchronously to the parser when the script
tag is encountered, e.g.:
.foo {
border: 1px solid black;
}
<div class="foo">
<script>document.write("I'm in the div");</script>
</div>
The modern way to do that is to manipulate the DOM afterward by
Selecting the target element(s), and
Inserting/removing/modifying content
I'm going to use id="the-div"
instead of id="1"
and class="the-class"
instead of class="2"
, because while it's possible to select your versions with CSS selectors, it's unnecessarily awkward (because they start with digits).
Here's an example selecting an element and modifying its content:
document.querySelector("#the-div .the-class").innerHTML = "I'm in the div";
.the-class {
border: 1px solid black;
}
<div id='the-div'>
<div class='the-class'>
</div>
</div>
You manipulate elements via the DOM (directly, or with libraries and/or frameworks like jQuery, Knockout, React, Vue.js, etc.).