/* main.js */
myP1 = document.createElement('p');
myP2 = document.createElement('p');
firstDiv = document.querySelector('div');
firstDiv.appendChild(myP1);
firstDiv.appendChild(myP1);
myP1.textContent = 'P1 here';
p2TextContent = myP2.textContent;
p2TextContent = 'P2 here';
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<div>
</div>
</body>
<script src = 'main.js'></script>
</html>
When myP2.textContent
is assigned to variable p2TextContent
, p2TextContent
should be bound to myP2.textContent
, and if modified p2TextContent
, myP2.textContent
should be modified at the same time. But why myP2.textContent
has not been modified?